Skip to content

Commit

Permalink
SAVEPOINT
Browse files Browse the repository at this point in the history
  • Loading branch information
lg2de committed Jan 14, 2023
1 parent 3d60b71 commit 373da79
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Src/FluentAssertions/AsyncAssertionsExtensions.cs
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using FluentAssertions.Execution;
using FluentAssertions.Specialized;

namespace FluentAssertions;
Expand All @@ -18,22 +19,20 @@ public static class AsyncAssertionsExtensions
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because"/>.
/// </param>
public static Task<AndWhichConstraint<GenericAsyncFunctionAssertions<T>, T>> WithResult<T>(
public static async Task<AndWhichConstraint<GenericAsyncFunctionAssertions<T>, T>> WithResult<T>(
this Task<AndWhichConstraint<GenericAsyncFunctionAssertions<T>, 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;
}

/// <summary>
Expand Down

0 comments on commit 373da79

Please sign in to comment.