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

New unit test to verify CompleteWithinAsync behaves correctly in an assertion scope #2033

Merged
merged 2 commits into from Nov 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions Tests/FluentAssertions.Specs/Specialized/TaskOfTAssertionSpecs.cs
Expand Up @@ -143,6 +143,28 @@ public async Task When_task_completes_late_it_should_fail()
await action.Should().ThrowAsync<XunitException>();
}

[Fact]
public async Task When_task_completes_late_it_in_assertion_scope_should_fail()
{
// Arrange
var timer = new FakeClock();
var taskFactory = new TaskCompletionSource<int>();

// Act
Func<Task> action = () =>
{
Func<Task<int>> func = () => taskFactory.Task;

using var _ = new AssertionScope();
return func.Should(timer).CompleteWithinAsync(100.Milliseconds());
};

timer.Complete();

// Assert
await action.Should().ThrowAsync<XunitException>();
}

[Fact]
public async Task When_task_consumes_time_in_sync_portion_it_should_fail()
{
Expand Down