Skip to content

Commit

Permalink
Rework logic slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminMichaelis committed Nov 4, 2023
1 parent 730b218 commit ac58f0d
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/Chapter19.Tests/Listing19.07.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter19.Listing19_07.Tests;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter19.Listing19_07.Tests;

[TestClass]
public class ProgramTests
Expand All @@ -8,14 +7,21 @@ public class ProgramTests
public void ValueTaskAsyncReturnTest()
{
string expected =
@"*:*:Sleeping for 2000 ms
*:*:Throwing exception.
*:*:Event handler starting
*:*:Sleeping for 4000 ms
*:*:Awake
*:*:Finally block running.";
@"Sleeping for 2000 ms
Throwing exception.
Event handler starting
Sleeping for 4000 ms
Awake
Finally block running.";

IntelliTect.TestTools.Console.ConsoleAssert.ExpectLike(expected,
Program.Main);
string output = IntelliTect.TestTools.Console.ConsoleAssert.Execute(string.Empty,
Program.Main).TrimEnd();

// Assert that all expected lines are present.
Assert.IsTrue(expected.Split(Environment.NewLine).All(output.Contains));

// Assert that the thread ID (first number in each line) is not the same for all lines.
Assert.AreEqual(2, output.Split(Environment.NewLine).Select(
line => line.Split(':')[0]).Distinct().Count());
}
}

0 comments on commit ac58f0d

Please sign in to comment.