diff --git a/ImperatorToCK3.UnitTests/Mappers/War/WarMapperTests.cs b/ImperatorToCK3.UnitTests/Mappers/War/WarMapperTests.cs index c957ecc5d..a5ca2e849 100644 --- a/ImperatorToCK3.UnitTests/Mappers/War/WarMapperTests.cs +++ b/ImperatorToCK3.UnitTests/Mappers/War/WarMapperTests.cs @@ -1,5 +1,7 @@ -using System.IO; +using commonItems.Mods; +using System.IO; using ImperatorToCK3.Mappers.War; +using System; using Xunit; namespace ImperatorToCK3.UnitTests.Mappers.War; @@ -58,4 +60,20 @@ public void MappingsAreReadFromFile() { Assert.Equal("vassalization_cb", mapper.GetCK3CBForImperatorWarGoal("imperial_conquest_wargoal")); Assert.Equal("imperial_reconquest_cb", mapper.GetCK3CBForImperatorWarGoal("diadochi_wargoal")); } + + [Fact] + public void UnmappedWarGoalsAreLogged() { + var mapper = new WarMapper("TestFiles/configurables/wargoal_mappings.txt"); + + var irModFS = new ModFilesystem("TestFiles/Imperator/game", Array.Empty()); + + var output = new StringWriter(); + Console.SetOut(output); + + mapper.DetectUnmappedWarGoals(irModFS); + + var outputString = output.ToString(); + Assert.DoesNotContain("No mapping for war goal independence_wargoal found in war goal mappings!", outputString); + Assert.Contains("No mapping for war goal unmapped_wargoal found in war goal mappings!", outputString); + } } \ No newline at end of file diff --git a/ImperatorToCK3.UnitTests/TestFiles/Imperator/game/common/wargoals/test_wargoals.txt b/ImperatorToCK3.UnitTests/TestFiles/Imperator/game/common/wargoals/test_wargoals.txt new file mode 100644 index 000000000..c21562f0a --- /dev/null +++ b/ImperatorToCK3.UnitTests/TestFiles/Imperator/game/common/wargoals/test_wargoals.txt @@ -0,0 +1,3 @@ +independence_wargoal = {} + +unmapped_wargoal = {} \ No newline at end of file diff --git a/ImperatorToCK3.sln.DotSettings b/ImperatorToCK3.sln.DotSettings index f275836e6..77e57d20b 100644 --- a/ImperatorToCK3.sln.DotSettings +++ b/ImperatorToCK3.sln.DotSettings @@ -4,6 +4,7 @@ AI BC BOM + CB CCU CK DB diff --git a/ImperatorToCK3/Mappers/War/WarMapping.cs b/ImperatorToCK3/Mappers/War/WarMapping.cs index c279f229a..41e6e8200 100644 --- a/ImperatorToCK3/Mappers/War/WarMapping.cs +++ b/ImperatorToCK3/Mappers/War/WarMapping.cs @@ -4,15 +4,15 @@ namespace ImperatorToCK3.Mappers.War; internal sealed class WarMapping { - public SortedSet ImperatorWarGoals { get; set; } = new(); - public string? CK3CasusBelli { get; set; } + public SortedSet ImperatorWarGoals { get; } = []; + public string? CK3CasusBelli { get; private set; } static WarMapping() { parser.RegisterKeyword("ck3", reader => mappingToReturn.CK3CasusBelli = reader.GetString()); parser.RegisterKeyword("ir", reader => mappingToReturn.ImperatorWarGoals.Add(reader.GetString())); parser.IgnoreAndLogUnregisteredItems(); } - public static WarMapping Parse (BufferedReader reader) { + public static WarMapping Parse(BufferedReader reader) { mappingToReturn = new WarMapping(); parser.ParseStream(reader); return mappingToReturn;