Beispiel #1
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.");
        }
Beispiel #2
0
        public void FaultedTaskShouldFail()
        {
            Task task = TaskBuilder.Faulted();

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

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

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

            act.ShouldNotThrow();
        }
Beispiel #4
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.");
        }
Beispiel #5
0
        public void ShouldAllowChainingWithWhich()
        {
            Task task = TaskBuilder.Faulted();

            Action act = () => task.Should().BeFaulted().Which.IsFaulted.Should().BeTrue();

            act.ShouldNotThrow();
        }
Beispiel #6
0
        public void FaultedTaskShouldPass()
        {
            Task task = TaskBuilder.Faulted();

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

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

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

            act.ShouldNotThrow();
        }
Beispiel #11
0
        public void ShouldAllowChainingWithAnd()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }