public async Task NotPerformsSideEffectOnNotSuccessfulResults() { var moqed = new Mock <ISideEffectsWrapper>(); var token = new CancellationTokenSource().Token; moqed .Setup(x => x.Effect()) .Verifiable(); moqed .Setup(x => x.CancellableEffect(It.Is <CancellationToken>(ct => ct.Equals(token)))) .Verifiable(); moqed .Setup(x => x.AsyncEffect()) .Verifiable(); moqed .Setup(x => x.CancellableEffect(It.Is <CancellationToken>(ct => ct.Equals(token)))) .Verifiable(); var fail = new TestException() .AsFail(); fail .EffectIfSuccessful(moqed.Object.Effect) .SideEffect(x => x .Should() .BeSameAs(fail)) .EffectIfSuccessful(moqed.Object.CancellableEffect, token) .SideEffect(x => x .Should() .BeSameAs(fail)); await fail .EffectIfSuccessfulAsync(moqed.Object.AsyncEffect) .ContinueWith(x => x.Result .Should() .BeSameAs(fail)); await fail .EffectIfSuccessfulAsync(moqed.Object.AsyncCancellableEffect, token) .ContinueWith(x => x.Result .Should() .BeSameAs(fail)); moqed .Verify(x => x.Effect(), Times.Never); moqed .Verify(x => x.CancellableEffect(It.Is <CancellationToken>(ct => ct.Equals(token))), Times.Never); moqed .Verify(x => x.AsyncEffect(), Times.Never); moqed .Verify(x => x.AsyncCancellableEffect(It.Is <CancellationToken>(ct => ct.Equals(token))), Times.Never); }