Exemplo n.º 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();
        }
Exemplo n.º 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.\"*");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 4
0
        public void ShouldAllowChainingWithTypedException()
        {
            Task <bool> task = TaskResultBuilder.Faulted();

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

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

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

            act.ShouldNotThrow();
        }
Exemplo n.º 7
0
        public void ShouldAllowChaining()
        {
            Task <bool> task = TaskResultBuilder.Completed();

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

            act.ShouldNotThrow();
        }
Exemplo n.º 8
0
        public void CanceledTaskShouldPass()
        {
            Task <bool> task = TaskResultBuilder.Canceled();

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

            act.ShouldNotThrow();
        }
Exemplo n.º 9
0
        public void FaultedTaskShouldPass()
        {
            Task <bool> task = TaskResultBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
Exemplo n.º 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.");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 12
0
        public void ShouldAllowChaining()
        {
            Task <bool> task = TaskResultBuilder.Canceled();

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

            act.ShouldNotThrow();
        }
Exemplo n.º 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.");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 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.");
        }
Exemplo n.º 17
0
        public void ShouldAllowChainingWithWhich()
        {
            Task <bool> task = TaskResultBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
Exemplo n.º 18
0
        public void PendingTaskShouldPass()
        {
            Task <bool> task = TaskResultBuilder.Pending();

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

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