Пример #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.");
        }
Пример #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.");
        }
Пример #3
0
        public void ShouldAllowChaining()
        {
            Task task = TaskBuilder.Faulted();

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

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

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

            act.ShouldNotThrow();
        }
Пример #6
0
        public void FaultedTaskShouldPass()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
Пример #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.");
        }
Пример #8
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.\"*");
        }
Пример #9
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();
        }
Пример #10
0
        public void ShouldAllowChainingWithTypedException()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }
Пример #11
0
        public void ShouldAllowChainingWithAnd()
        {
            Task task = TaskBuilder.Faulted();

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

            act.ShouldNotThrow();
        }