public void CheckForExceptionShouldThrowIfExceptionNotNullWithMessage() { Test.AssertException <InvocationAssertionException>( () => { InvocationValidator.CheckForException(new NullReferenceException("Test"), "Test"); }, "Test no exception but NullReferenceException with 'Test' message was thrown without being caught."); }
public void CheckForExceptionShouldThrowWithProperMessageIfExceptionIsAggregateException() { var aggregateException = new AggregateException(new List <Exception> { new NullReferenceException("Null test"), new InvalidCastException("Cast test"), new InvalidOperationException("Operation test") }); Test.AssertException <InvocationAssertionException>( () => { InvocationValidator.CheckForException(aggregateException, "Test"); }, "Test no exception but AggregateException (containing NullReferenceException with 'Null test' message, InvalidCastException with 'Cast test' message, InvalidOperationException with 'Operation test' message) was thrown without being caught."); }
public void CheckForExceptionShouldNotThrowIfExceptionNull() { InvocationValidator.CheckForException(null, string.Empty); }
/// <inheritdoc /> public IShouldHaveTestBuilder <VoidMethodResult> ShouldHave() { InvocationValidator.CheckForException(this.CaughtException, this.TestContext.ExceptionMessagePrefix); return(new ShouldHaveTestBuilder <VoidMethodResult>(this.TestContext)); }
/// <inheritdoc /> public IBaseTestBuilderWithInvokedAction ShouldReturnEmpty() { TestHelper.ExecuteTestCleanup(); InvocationValidator.CheckForException(this.CaughtException, this.TestContext.ExceptionMessagePrefix); return(this.NewAndTestBuilderWithInvokedAction()); }
/// <inheritdoc /> public IShouldReturnTestBuilder <TActionResult> ShouldReturn() { TestHelper.ExecuteTestCleanup(); InvocationValidator.CheckForException(this.CaughtException, this.TestContext.ExceptionMessagePrefix); return(new ShouldReturnTestBuilder <TActionResult>(this.TestContext)); }
/// <inheritdoc /> public IViewComponentShouldHaveTestBuilder <TInvocationResult> ShouldHave() { InvocationValidator.CheckForException(this.CaughtException, this.TestContext.ExceptionMessagePrefix); return(new ViewComponentShouldHaveTestBuilder <TInvocationResult>(this.TestContext)); }