Skip to content

Commit

Permalink
New unit test to verify CompleteWithinAsync behaves correctly in an a…
Browse files Browse the repository at this point in the history
…ssertion scope (#2033)

* Add new unit test to verify #2004

* fix test name
  • Loading branch information
lg2de committed Nov 19, 2022
1 parent b900216 commit 9bb74f1
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit 9bb74f1

Please sign in to comment.