From 373da790622e93633641b8be2c6ead0ca45fd159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Gr=C3=BCtzmacher?= Date: Sat, 14 Jan 2023 20:50:19 +0100 Subject: [PATCH] SAVEPOINT --- Src/FluentAssertions/AsyncAssertionsExtensions.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Src/FluentAssertions/AsyncAssertionsExtensions.cs b/Src/FluentAssertions/AsyncAssertionsExtensions.cs index 4275215ec0..b718d87cc5 100644 --- a/Src/FluentAssertions/AsyncAssertionsExtensions.cs +++ b/Src/FluentAssertions/AsyncAssertionsExtensions.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using FluentAssertions.Execution; using FluentAssertions.Specialized; namespace FluentAssertions; @@ -18,22 +19,20 @@ public static class AsyncAssertionsExtensions /// /// Zero or more objects to format using the placeholders in . /// - public static Task, T>> WithResult( + public static async Task, T>> WithResult( this Task, T>> task, T expected, string because = "", params object[] becauseArgs) { - if (!task.IsCompleted) // TODO Diese Task ist nicht die richtige... + if (AssertionScope.Current.HasFailures()) { - // The task is not completed, this means the previous assertion was failed. - // There is no result which can be checked. - return task; + return null; } - var andWhichConstraint = task.Result; + var andWhichConstraint = await task; var subject = andWhichConstraint.Subject; subject.Should().Be(expected, because, becauseArgs); - return task; + return andWhichConstraint; } ///