예제 #1
0
        public void CanceledTaskShouldPass()
        {
            Task task = TaskBuilder.Canceled();

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

            act.ShouldNotThrow();
        }
예제 #2
0
        public void ShouldAllowChainingWithAnd()
        {
            Task task = TaskBuilder.Canceled();

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

            act.ShouldNotThrow();
        }
예제 #3
0
        public void ShouldAllowChainingWithWhich()
        {
            Task task = TaskBuilder.Canceled();

            Action act = () => task.Should().BeCanceled().Which.IsCanceled.Should().BeTrue();

            act.ShouldNotThrow();
        }
예제 #4
0
        public void PendingTaskShouldFailWithReasonFormatted()
        {
            Task task = TaskBuilder.Pending();

            Action act = () => task.Should().BeCompletedSuccessfully("I said {0}", "so");

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be completed successfully because I said so but was WaitingForActivation.");
        }
예제 #5
0
        public void WithExceptionShouldPassIfAtLeastOneExceptionMatches()
        {
            Task task = TaskBuilder.Faulted(new InvalidCastException("Expected failure."), new InvalidProgramException("Other expected failure."));

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

            act.ShouldNotThrow();
        }
예제 #6
0
        public void ShouldAllowChainingWithAnd()
        {
            Task task = TaskBuilder.Completed();

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

            act.ShouldNotThrow();
        }
예제 #7
0
        public void CompletedTaskShouldPass()
        {
            Task task = TaskBuilder.Completed();

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

            act.ShouldNotThrow();
        }
예제 #8
0
        public void FaultedTaskShouldFailWithReason()
        {
            Task task = TaskBuilder.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.");
        }
예제 #9
0
        public void CanceledTaskShouldFail()
        {
            Task task = TaskBuilder.Canceled();

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

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be pending but was Canceled.");
        }
예제 #10
0
        public void ShouldAllowChainingWithWhich()
        {
            Task task = TaskBuilder.Pending();

            Action act = () => task.Should().BePending().Which.IsCompleted.Should().BeFalse();

            act.ShouldNotThrow();
        }
예제 #11
0
        public void PendingTaskShouldPass()
        {
            Task task = TaskBuilder.Pending();

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

            act.ShouldNotThrow();
        }
예제 #12
0
        public void WithExceptionShouldFailOnNullExceptionWithReasonFormatted()
        {
            Task task = TaskBuilder.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.");
        }
예제 #13
0
        public void WithExceptionShouldFailOnNullException()
        {
            Task task = TaskBuilder.Completed();

            Action act = () => task.Should().BeCompleted().WithException <InvalidCastException>();

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected a <System.InvalidCastException> to be thrown, but no exception was thrown.");
        }
예제 #14
0
        public void WithExceptionShouldFailIfNoExceptionMatches()
        {
            Task task = TaskBuilder.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.\"*");
        }
예제 #15
0
        public void FaultedTaskShouldFail()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be canceled but was Faulted.");
        }
예제 #16
0
        public void FaultedTaskShouldPass()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
예제 #17
0
        public void FaultedTaskShouldFailWithReasonFormatted()
        {
            Task task = TaskBuilder.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.");
        }
예제 #18
0
        public void PendingTaskShouldFailWithReason()
        {
            Task task = TaskBuilder.Pending();

            Action act = () => task.Should().BeFaulted(because: "I said so");

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be faulted because I said so but was WaitingForActivation.");
        }
예제 #19
0
        public void ShouldAllowChainingWithWhich()
        {
            Task task = TaskBuilder.Completed();

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

            act.ShouldNotThrow();
        }
예제 #20
0
        public void CompletedTaskShouldFail()
        {
            Task task = TaskBuilder.Completed();

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

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be faulted but was RanToCompletion.");
        }
예제 #21
0
        public void PendingTaskShouldFail()
        {
            Task task = TaskBuilder.Pending();

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

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be completed successfully but was WaitingForActivation.");
        }
예제 #22
0
        public void ShouldAllowChaining()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
예제 #23
0
        public void CanceledTaskShouldFail()
        {
            Task task = TaskBuilder.Canceled();

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

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be completed successfully but was Canceled.");
        }
예제 #24
0
        public void ShouldAllowChainingWithTypedException()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }