Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Un-ignore test 19.07 #579

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/Chapter19.Tests/Listing19.07.Tests.cs
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void Delay(int i)
static void Message(string text)
{
Console.WriteLine("{0}:{1:0000}:{2}",
Thread.CurrentThread.ManagedThreadId,
Environment.CurrentManagedThreadId,
Clock.ElapsedMilliseconds, text);
}
}
Expand Down
Loading