From 1caa5215a6b1c9851bc339d9a27216e50fc96989 Mon Sep 17 00:00:00 2001 From: IhateTrains Date: Sun, 6 Aug 2023 19:48:50 +0200 Subject: [PATCH] Update tests (#1463) --- .../Mappers/Region/CK3RegionMapperTests.cs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ImperatorToCK3.UnitTests/Mappers/Region/CK3RegionMapperTests.cs b/ImperatorToCK3.UnitTests/Mappers/Region/CK3RegionMapperTests.cs index 69c980d2f..25d1f16e6 100644 --- a/ImperatorToCK3.UnitTests/Mappers/Region/CK3RegionMapperTests.cs +++ b/ImperatorToCK3.UnitTests/Mappers/Region/CK3RegionMapperTests.cs @@ -2,6 +2,7 @@ using commonItems.Mods; using ImperatorToCK3.CK3.Titles; using ImperatorToCK3.Mappers.Region; +using System; using System.Collections.Generic; using System.IO; using Xunit; @@ -38,9 +39,11 @@ public void LoadingBrokenRegionWillThrowException() { const string ck3Path = "TestFiles/regions/CK3RegionMapperTests/LoadingBrokenRegionWillThrowException"; var ck3Root = Path.Combine(ck3Path, "game"); var ck3ModFS = new ModFilesystem(ck3Root, new List()); - void action() => mapper.LoadRegions(ck3ModFS, landedTitles); - KeyNotFoundException exception = Assert.Throws(action); - Assert.Equal("Region's test_region2 region test_region does not exist!", exception.Message); + + var output = new StringWriter(); + Console.SetOut(output); + mapper.LoadRegions(ck3ModFS, landedTitles); + Assert.Contains("Region's test_region2 region test_region does not exist!", output.ToString()); } [Fact] public void LoadingBrokenDuchyWillThrowException() { @@ -53,9 +56,11 @@ public void LoadingBrokenDuchyWillThrowException() { const string ck3Path = "TestFiles/regions/CK3RegionMapperTests/LoadingBrokenDuchyWillThrowException"; var ck3Root = Path.Combine(ck3Path, "game"); var ck3ModFS = new ModFilesystem(ck3Root, new List()); - void action() => mapper.LoadRegions(ck3ModFS, landedTitles); - KeyNotFoundException exception = Assert.Throws(action); - Assert.Equal("Region's test_region duchy d_aquitane does not exist!", exception.Message); + + var output = new StringWriter(); + Console.SetOut(output); + mapper.LoadRegions(ck3ModFS, landedTitles); + Assert.Contains("Region's test_region duchy d_aquitane does not exist!", output.ToString()); } [Fact] public void LoadingBrokenCountyWillThrowException() { @@ -68,9 +73,11 @@ public void LoadingBrokenCountyWillThrowException() { const string ck3Path = "TestFiles/regions/CK3RegionMapperTests/LoadingBrokenCountyWillThrowException"; var ck3Root = Path.Combine(ck3Path, "game"); var ck3ModFS = new ModFilesystem(ck3Root, new List()); - void Action() => mapper.LoadRegions(ck3ModFS, landedTitles); - KeyNotFoundException exception = Assert.Throws(Action); - Assert.Equal("Region's test_region county c_mers does not exist!", exception.Message); + + var output = new StringWriter(); + Console.SetOut(output); + mapper.LoadRegions(ck3ModFS, landedTitles); + Assert.Contains("Region's test_region county c_mers does not exist!", output.ToString()); } [Fact]