-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
| ||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter19.Listing19_07.Tests; | ||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter19.Listing19_07.Tests; | ||
|
||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod][Ignore] | ||
[TestMethod] | ||
public void ValueTaskAsyncReturnTest() | ||
{ | ||
string expected = @"3:0047:Throwing exception. | ||
3:0052:Unhandled exception handler starting. | ||
3:0055:Sleeping for 4000 ms | ||
1:0058:Sleeping for 2000 ms | ||
1:2059:Awake | ||
1:2060:Finally block running. | ||
3:4059:Awake | ||
Unhandled Exception: System.Exception: Exception of type 'System.Exception' was thrown. | ||
"; | ||
string expected = | ||
@"Sleeping for 2000 ms | ||
Throwing exception. | ||
Event handler starting | ||
Sleeping for 4000 ms | ||
Awake | ||
Finally block running."; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect(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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters