diff --git a/Tests/FluentAssertions.Specs/Execution/CallerIdentifierSpecs.cs b/Tests/FluentAssertions.Specs/Execution/CallerIdentifierSpecs.cs index 96098ebde3..a539f4f942 100644 --- a/Tests/FluentAssertions.Specs/Execution/CallerIdentifierSpecs.cs +++ b/Tests/FluentAssertions.Specs/Execution/CallerIdentifierSpecs.cs @@ -452,6 +452,22 @@ public void When_the_method_has_Should_prefix_it_should_read_whole_method() act.Should().Throw() .WithMessage("Expected foo.ShouldReturnSomeBool() to be false*"); } + + [UIFact] + public async Task Caller_identification_should_also_work_for_statements_following_async_code() + { + // Arrange + const string someText = "Hello"; + Func task = async () => await Task.Yield(); + + // Act + await task.Should().NotThrowAsync(); + Action act = () => someText.Should().Be("Hi"); + + // Assert + act.Should().Throw() + .WithMessage("*someText*", "it should capture the variable name"); + } } [SuppressMessage("The name of a C# element does not begin with an upper-case letter", "SA1300")] diff --git a/Tests/FluentAssertions.Specs/Specialized/TaskAssertionSpecs.cs b/Tests/FluentAssertions.Specs/Specialized/TaskAssertionSpecs.cs index 7c7fb8c52b..3f6f5237f9 100644 --- a/Tests/FluentAssertions.Specs/Specialized/TaskAssertionSpecs.cs +++ b/Tests/FluentAssertions.Specs/Specialized/TaskAssertionSpecs.cs @@ -143,21 +143,5 @@ async Task CheckContextAsync() SynchronizationContext.Current.Should().NotBeNull(); } } - - [UIFact] - public async Task When_resolving_async_to_main_thread_variable_name_used_for_assertion_should_be_detected() - { - // Arrange - const string someText = "Hello"; - Func task = async () => await Task.Yield(); - - // Act - await task.Should().NotThrowAsync(); - Action act = () => someText.Should().Be("Hi"); - - // Assert - act.Should().Throw() - .WithMessage("*someText*", "it should capture the variable name"); - } } }