示例#1
0
        public void VerifyShouldNotReturnNull()
        {
            // arrange
            var assert = new ExceptionAsserter <Exception>(new Exception());

            // act
            var actual = assert.Verify(e => true);

            // assert
            Assert.IsNotNull(actual);
        }
示例#2
0
        public void VerifyShouldAssertFailedVerification()
        {
            // arrange
            var assert = new ExceptionAsserter <Exception>(new Exception());

            try
            {
                // act
                assert.Verify(e => false);
            }
            catch (AssertFailedException)
            {
                // assert
                return;
            }

            Assert.Fail("An exception was expected, but not thrown.");
        }
示例#3
0
        public void VerifyShouldAssertFailedVerificationWithMessage()
        {
            // arrange
            var assert = new ExceptionAsserter <Exception>(new Exception());

            try
            {
                // act
                assert.Verify(exception => false, "A '{0}' message.", "test");
            }
            catch (AssertFailedException ex)
            {
                // assert
                Assert.AreEqual("Assert.IsTrue failed. A 'test' message.", ex.Message);
                return;
            }

            Assert.Fail("An exception was expected, but not thrown.");
        }
示例#4
0
        public void VerifyShouldNotAllowNullVerificationFunctionWithMessage()
        {
            // arrange
            var assert       = new ExceptionAsserter <Exception>(new Exception());
            var verification = default(Func <Exception, bool>);

            try
            {
                // act
                assert.Verify(verification, string.Empty);
            }
            catch (AssertFailedException ex)
            {
                // asseert
                Assert.AreEqual(GetExpectedMessage(nameof(verification)), ex.Message);
                return;
            }

            Assert.Fail("An exception was expected, but not thrown.");
        }