Beispiel #1
0
        public void CompletedTaskShouldPass()
        {
            Task task = TaskBuilder.Completed();

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

            act.ShouldNotThrow();
        }
Beispiel #2
0
        public void ShouldAllowChainingWithWhich()
        {
            Task task = TaskBuilder.Completed();

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

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

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

            act.ShouldNotThrow();
        }
Beispiel #4
0
        public void CompletedTaskShouldFail()
        {
            Task task = TaskBuilder.Completed();

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

            act.ShouldThrow <AssertFailedException>().WithMessage("Expected task to be canceled but was RanToCompletion.");
        }
        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.");
        }