public void GivenAppExceptionRuleWhenDerivedFromDerivativeExceptionProvidedThenShouldAdviceToHandle() { // Arrange var sut = new ExceptionRuleForErrorProvider <ApplicationExceptionBase>(); var exception = new OurDerivedApplicationException("Error"); // Act var result = sut.CanHandle(exception); // Assert Assert.True(result); }
public void ShouldExtractDerivedExceptionMessages() { // Arrange var options = Substitute.For <IErrorProviderOptions>(); options.IncludeSystemLevelExceptions.Returns(false); options.ExceptionsToHandle.Returns(new List <IExceptionRule> { new ExceptionRuleForErrorProvider <ApplicationExceptionBase>() }); var internalError = new OurDerivedApplicationException("Derived Error"); var exception = new Exception("Internal Error", internalError); var sut = new ErrorProvider(); // Act var result = sut.ExtractErrorsFor(exception, options); // Assert Assert.Equal("Derived Error", result.Message); Assert.Equal("OurDerivedApplicationException", result.ErrorType); Assert.Empty(result.ChildErrors); }