/
Continuation.cs
30 lines (26 loc) · 979 Bytes
/
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
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;
}
/// <summary>
/// Continuous the assertion chain if the previous assertion was successful.
/// </summary>
public AssertionScope Then => sourceScope.CreateChainableScope();
public bool SourceSucceeded => sourceScope.Succeeded;
/// <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;
}
}
}