public void InnerHandler_ReturnsSpecifiedInstance()
        {
            // Arrange
            IExceptionHandler          expectedInnerHandler = CreateDummyHandler();
            LastChanceExceptionHandler product = CreateProductUnderTest(expectedInnerHandler);

            // Act
            IExceptionHandler innerHandler = product.InnerHandler;

            // Assert
            Assert.Same(expectedInnerHandler, innerHandler);
        }
Example #2
0
        private static ServicesContainer CreateServices(IExceptionHandler handler)
        {
            Mock <ServicesContainer> mock = new Mock <ServicesContainer>(MockBehavior.Strict);

            mock.Setup(s => s.GetService(typeof(IExceptionHandler))).Returns(handler);
            LastChanceExceptionHandler cached = null;

            mock.Setup(s => s.GetService(typeof(LastChanceExceptionHandler))).Returns(() => cached);
            mock.Protected()
            .Setup("ReplaceSingle", typeof(LastChanceExceptionHandler), ItExpr.IsAny <object>())
            .Callback <Type, object>((i, o) => cached = (LastChanceExceptionHandler)o);
            mock.Setup(s => s.IsSingleService(typeof(LastChanceExceptionHandler))).Returns(true);
            mock.Protected().Setup("ResetCache", typeof(LastChanceExceptionHandler));
            mock.Setup(s => s.Dispose());
            return(mock.Object);
        }