/
Continuation.cs
31 lines (27 loc) · 1.01 KB
/
Continuation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace FluentAssertions.Execution
{
/// <summary>
/// Enables chaining multiple assertions on an <see cref="AssertionScope"/>.
/// </summary>
public class Continuation
{
private readonly AssertionScope sourceScope;
public Continuation(AssertionScope sourceScope, bool sourceSucceeded)
{
this.sourceScope = sourceScope;
SourceSucceeded = sourceSucceeded;
}
/// <summary>
/// Continuous the assertion chain if the previous assertion was successful.
/// </summary>
public IAssertionScope Then => new ContinuedAssertionScope(sourceScope, SourceSucceeded);
public bool SourceSucceeded { get; }
/// <summary>
/// Provides back-wards compatibility for code that expects <see cref="AssertionScope.FailWith"/> to return a boolean.
/// </summary>
public static implicit operator bool(Continuation continuation)
{
return continuation.SourceSucceeded;
}
}
}