public void IfGetLoggerFailsExceptionIsHandled() { // Arrange SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator().RegisterTypeMapping <ILogger, BadLogger>()); var originalException = new InvalidOperationException("Bad Error"); var target = new TestableBaseRobustExceptionHandler(); try { // Act target.CallGetLogger(originalException); // Assert Assert.Fail(); } catch (ExceptionHandlingException ex) { Assert.AreSame(originalException, ex.InnerException); Assert.IsInstanceOfType(ex.HandlingException, typeof(ActivationException)); Assert.IsTrue(ex.Message.Contains("Bad Error")); } catch (Exception) { Assert.Fail(); } }
public void WillNotHideExceptionDetailsIfHandlingFailes() { // Arrange var originalException = new ArgumentException("MyMessage"); var target = new TestableBaseRobustExceptionHandler(); try { // Act target.HandleException(originalException); // Assert Assert.Fail(); } catch (ExceptionHandlingException ex) { // Assert Assert.AreSame(originalException, ex.InnerException); Assert.IsTrue(originalException.Message.Contains("MyMessage")); Assert.IsInstanceOfType(ex.HandlingException, typeof(AccessViolationException)); } catch (Exception) { Assert.Fail(); } }