public void WithExceptionShouldPassIfAtLeastOneExceptionMatches() { Task <bool> task = TaskResultBuilder.Faulted(new InvalidCastException("Expected failure."), new InvalidProgramException("Other expected failure.")); Action act = () => task.Should().BeCompleted().WithException <InvalidCastException>().WithMessage("Expected failure."); act.ShouldNotThrow(); }
public void WithExceptionShouldFailIfNoExceptionMatches() { Task <bool> task = TaskResultBuilder.Faulted(new InvalidOperationException("Unexpected failure.")); Action act = () => task.Should().BeCompleted().WithException <InvalidCastException>(); act.ShouldThrow <AssertFailedException>().WithMessage("Expected a <System.InvalidCastException> to be thrown, but found a*System.InvalidOperationException with message \"Unexpected failure.\"*"); }
public void CompletedTaskShouldFail() { Task <bool> task = TaskResultBuilder.Completed(); Action act = () => task.Should().BePending(); act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be pending but was RanToCompletion."); }
public void ShouldAllowChainingWithTypedException() { Task <bool> task = TaskResultBuilder.Faulted(); Action act = () => task.Should().BeCompleted().WithException <InvalidCastException>().WithMessage("Expected failure."); act.ShouldNotThrow(); }
public void CanceledTaskShouldFail() { Task <bool> task = TaskResultBuilder.Canceled(); Action act = () => task.Should().BeCompletedSuccessfully(); act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be completed successfully but was Canceled."); }
public void ShouldAllowChainingWithAnd() { Task <bool> task = TaskResultBuilder.Faulted(); Action act = () => task.Should().BeCompleted().And.BeCompleted(); act.ShouldNotThrow(); }
public void ShouldAllowChaining() { Task <bool> task = TaskResultBuilder.Completed(); Action act = () => task.Should().BeCompletedSuccessfully().BeCompletedSuccessfully(); act.ShouldNotThrow(); }
public void CanceledTaskShouldPass() { Task <bool> task = TaskResultBuilder.Canceled(); Action act = () => task.Should().BeCompleted(); act.ShouldNotThrow(); }
public void FaultedTaskShouldPass() { Task <bool> task = TaskResultBuilder.Faulted(); Action act = () => task.Should().BeFaulted(); act.ShouldNotThrow(); }
public void CanceledTaskShouldFail() { Task <bool> task = TaskResultBuilder.Canceled(); Action act = () => task.Should().BeFaulted(); act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be faulted but was Canceled."); }
public void FaultedTaskShouldFailWithReasonFormatted() { Task <bool> task = TaskResultBuilder.Faulted(); Action act = () => task.Should().BeCanceled("I said {0}", "so"); act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be canceled because I said so but was Faulted."); }
public void ShouldAllowChaining() { Task <bool> task = TaskResultBuilder.Canceled(); Action act = () => task.Should().BeCanceled().BeCanceled(); act.ShouldNotThrow(); }
public void FaultedTaskShouldFailWithReason() { Task <bool> task = TaskResultBuilder.Faulted(); Action act = () => task.Should().BePending(because: "I said so"); act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be pending because I said so but was Faulted."); }
public void WithExceptionShouldFailOnNullExceptionWithReasonFormatted() { Task <bool> task = TaskResultBuilder.Completed(); Action act = () => task.Should().BeCompleted().WithException <InvalidCastException>("I said {0}", "so"); act.ShouldThrow <AssertFailedException>().WithMessage("Expected a <System.InvalidCastException> to be thrown because I said so, but no exception was thrown."); }
public void PendingTaskShouldFail() { Task <bool> task = TaskResultBuilder.Pending(); Action act = () => task.Should().BeCompletedSuccessfully(); act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be completed successfully but was WaitingForActivation."); }
public void PendingTaskShouldFailWithReasonFormatted() { Task <bool> task = TaskResultBuilder.Pending(); Action act = () => task.Should().BeCompleted("I said {0}", "so"); act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be completed because I said so but was WaitingForActivation."); }
public void ShouldAllowChainingWithWhich() { Task <bool> task = TaskResultBuilder.Faulted(); Action act = () => task.Should().BeCompleted().Which.IsCompleted.Should().BeTrue(); act.ShouldNotThrow(); }
public void PendingTaskShouldPass() { Task <bool> task = TaskResultBuilder.Pending(); Action act = () => task.Should().BePending(); act.ShouldNotThrow(); }
public static Task Canceled() { return(TaskResultBuilder.Canceled()); }
public static Task Pending() { return(TaskResultBuilder.Pending()); }
public static Task Faulted(params Exception[] exceptions) { return(TaskResultBuilder.Faulted(exceptions)); }
public static Task Completed() { return(TaskResultBuilder.Completed()); }