public void VerifyShouldNotReturnNull() { // arrange var assert = new ExceptionAsserter <Exception>(new Exception()); // act var actual = assert.Verify(e => true); // assert Assert.IsNotNull(actual); }
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."); }
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."); }
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."); }