diff --git a/ListingManager.Tests/ConsoleOutputCollection.cs b/ListingManager.Tests/ConsoleOutputCollection.cs new file mode 100644 index 0000000..a515282 --- /dev/null +++ b/ListingManager.Tests/ConsoleOutputCollection.cs @@ -0,0 +1,9 @@ +using Xunit; + +namespace EssentialCSharp.ListingManager.Tests; + +[CollectionDefinition(Name, DisableParallelization = true)] +public sealed class ConsoleOutputCollection +{ + public const string Name = "Console output collection"; +} diff --git a/ListingManager.Tests/ScanManagerTests.cs b/ListingManager.Tests/ScanManagerTests.cs index b33b8fd..39a6b85 100644 --- a/ListingManager.Tests/ScanManagerTests.cs +++ b/ListingManager.Tests/ScanManagerTests.cs @@ -1,8 +1,8 @@ -using IntelliTect.TestTools.Console; -using Xunit; +using Xunit; namespace EssentialCSharp.ListingManager.Tests; +[Collection(ConsoleOutputCollection.Name)] public class ScanManagerTests : TempFileTestBase { [Fact] @@ -18,8 +18,11 @@ public void ScanForMissingTests() Path.Join("Chapter02.Tests","Listing02.06.Something.Tests.cs") }; - const string expected = @"Missing test for 1.1 -Missing test for 2.4"; + List expected = new() + { + "Missing test for 1.1", + "Missing test for 2.4" + }; List toWrite = [ @@ -37,6 +40,23 @@ public void ScanForMissingTests() CreateTempDirectory(tempDir, "Chapter02.Tests"); WriteFiles(tempDir, filesToMake, toWrite); - ConsoleAssert.Expect(expected, () => ScanManager.ScanForAllMissingTests(tempDir, false)); + TextWriter originalOut = Console.Out; + using StringWriter output = new(); + try + { + Console.SetOut(output); + ScanManager.ScanForAllMissingTests(tempDir, false); + } + finally + { + Console.SetOut(originalOut); + } + + List actual = output.ToString() + .Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries) + .OrderBy(line => line, StringComparer.Ordinal) + .ToList(); + + Assert.Equal(expected.OrderBy(line => line, StringComparer.Ordinal), actual); } }