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

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

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

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

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

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

            act.ShouldNotThrow();
        }
Exemple #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.");
        }
        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();
        }
Exemple #6
0
        public void ShouldAllowChainingWithAnd()
        {
            Task task = TaskBuilder.Completed();

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

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

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

            act.ShouldNotThrow();
        }
        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.");
        }
        public void CanceledTaskShouldFail()
        {
            Task task = TaskBuilder.Canceled();

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

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

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

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

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

            act.ShouldNotThrow();
        }
        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.");
        }
        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.");
        }
        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.\"*");
        }
Exemple #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.");
        }
Exemple #16
0
        public void FaultedTaskShouldPass()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
Exemple #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.");
        }
Exemple #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.");
        }
Exemple #19
0
        public void ShouldAllowChainingWithWhich()
        {
            Task task = TaskBuilder.Completed();

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

            act.ShouldNotThrow();
        }
Exemple #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.");
        }
Exemple #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.");
        }
Exemple #22
0
        public void ShouldAllowChaining()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
Exemple #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.");
        }
        public void ShouldAllowChainingWithTypedException()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }