Esempio n. 1
0
        public void DoesThrow_WrappedInAction_ThrowInvalidOperationException()
        {
            // Arrange
            var subject = new Thrower();

            // Act
            Action act = () => subject.DoesThrow();

            // Assert
            act.Should().Throw <InvalidOperationException>();
        }
Esempio n. 2
0
        public void DoesThrow_ThrowInvalidOperationAdvanced()
        {
            // *  Throw InvalidOperationException,
            //  * which exception message contains "foobar"
            // * the InvalidOperationException has an InnerException,
            //  * which is exactly DivideByZeroException,
            //  * which exception message contains "Dark Side"

            // Arrange
            var subject = new Thrower();

            // Act
            Action act = () => subject.DoesThrow();

            // Assert
            act.Should().Throw <InvalidOperationException>()
            .WithMessage("*foobar*")
            .WithInnerExceptionExactly <DivideByZeroException>()
            .WithMessage("*Dark Side*");
        }