public static TimeLimiter Compose(params IAwaitableConstraint[] constraints) { IAwaitableConstraint current = null; foreach (var constraint in constraints) { current = (current == null) ? constraint : current.Compose(constraint); } return(new TimeLimiter(current)); }
public AwaitableConstraintExtensionTests() { _AwaitableConstraint1 = Substitute.For <IAwaitableConstraint>(); _AwaitableConstraint2 = Substitute.For <IAwaitableConstraint>(); _Disposable1 = Substitute.For <IDisposable>(); _Disposable2 = Substitute.For <IDisposable>(); _AwaitableConstraint1.WaitForReadiness(Arg.Any <CancellationToken>()).Returns(Task.FromResult(_Disposable1)); _AwaitableConstraint2.WaitForReadiness(Arg.Any <CancellationToken>()).Returns(Task.FromResult(_Disposable2)); _Composed = _AwaitableConstraint1.Compose(_AwaitableConstraint2); }
public void Compose_returns_self_if_constraint_is_the_same() { var composed = _AwaitableConstraint1.Compose(_AwaitableConstraint1); composed.Should().Be(_AwaitableConstraint1); }