Exemple #1
0
        public void IfGetLoggerFailsExceptionIsHandled()
        {
            SharePointServiceLocator.ReplaceCurrentServiceLocator(new ActivatingServiceLocator().RegisterTypeMapping <ILogger, BadLogger>());

            var originalException = new InvalidOperationException("Bad Error");

            var target = new TestableBaseRobustExceptionHandler();

            try
            {
                target.CallGetLogger(originalException);
                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();
            }
        }
Exemple #2
0
        public void WillNotHideExceptionDetailsIfHandlingFailes()
        {
            var originalException = new ArgumentException("MyMessage");
            var target            = new TestableBaseRobustExceptionHandler();

            try
            {
                target.HandleException(originalException);
                Assert.Fail();
            }
            catch (ExceptionHandlingException ex)
            {
                Assert.AreSame(originalException, ex.InnerException);
                Assert.IsTrue(originalException.Message.Contains("MyMessage"));
                Assert.IsInstanceOfType(ex.HandlingException, typeof(AccessViolationException));
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }