예제 #1
0
        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();
        }
예제 #2
0
        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.\"*");
        }
예제 #3
0
        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.");
        }
예제 #4
0
        public void ShouldAllowChainingWithTypedException()
        {
            Task <bool> task = TaskResultBuilder.Faulted();

            Action act = () => task.Should().BeCompleted().WithException <InvalidCastException>().WithMessage("Expected failure.");

            act.ShouldNotThrow();
        }
예제 #5
0
        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.");
        }
예제 #6
0
        public void ShouldAllowChainingWithAnd()
        {
            Task <bool> task = TaskResultBuilder.Faulted();

            Action act = () => task.Should().BeCompleted().And.BeCompleted();

            act.ShouldNotThrow();
        }
예제 #7
0
        public void ShouldAllowChaining()
        {
            Task <bool> task = TaskResultBuilder.Completed();

            Action act = () => task.Should().BeCompletedSuccessfully().BeCompletedSuccessfully();

            act.ShouldNotThrow();
        }
예제 #8
0
        public void CanceledTaskShouldPass()
        {
            Task <bool> task = TaskResultBuilder.Canceled();

            Action act = () => task.Should().BeCompleted();

            act.ShouldNotThrow();
        }
예제 #9
0
        public void FaultedTaskShouldPass()
        {
            Task <bool> task = TaskResultBuilder.Faulted();

            Action act = () => task.Should().BeFaulted();

            act.ShouldNotThrow();
        }
예제 #10
0
        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.");
        }
예제 #11
0
        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.");
        }
예제 #12
0
        public void ShouldAllowChaining()
        {
            Task <bool> task = TaskResultBuilder.Canceled();

            Action act = () => task.Should().BeCanceled().BeCanceled();

            act.ShouldNotThrow();
        }
예제 #13
0
        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.");
        }
예제 #14
0
        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.");
        }
예제 #15
0
        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.");
        }
예제 #16
0
        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.");
        }
예제 #17
0
        public void ShouldAllowChainingWithWhich()
        {
            Task <bool> task = TaskResultBuilder.Faulted();

            Action act = () => task.Should().BeCompleted().Which.IsCompleted.Should().BeTrue();

            act.ShouldNotThrow();
        }
예제 #18
0
        public void PendingTaskShouldPass()
        {
            Task <bool> task = TaskResultBuilder.Pending();

            Action act = () => task.Should().BePending();

            act.ShouldNotThrow();
        }
예제 #19
0
 public static Task Canceled()
 {
     return(TaskResultBuilder.Canceled());
 }
예제 #20
0
 public static Task Pending()
 {
     return(TaskResultBuilder.Pending());
 }
예제 #21
0
 public static Task Faulted(params Exception[] exceptions)
 {
     return(TaskResultBuilder.Faulted(exceptions));
 }
예제 #22
0
 public static Task Completed()
 {
     return(TaskResultBuilder.Completed());
 }