コード例 #1
0
        public void ExceptionHandlerGet_IfUnset_UsesExceptionHandlerFromConfiguration()
        {
            // Arrange
            using (HttpConfiguration configuration = CreateConfiguration())
            {
                IExceptionHandler expectedExceptionHandler = CreateDummyExceptionHandler();
                configuration.Services.Replace(typeof(IExceptionHandler), expectedExceptionHandler);

                using (HttpControllerDispatcher product = CreateProductUnderTest(configuration))
                {
                    // Act
                    IExceptionHandler exceptionHandler = product.ExceptionHandler;

                    // Assert
                    LastChanceExceptionHandler lastChanceHandler = Assert.IsType <LastChanceExceptionHandler>(exceptionHandler);
                    Assert.Same(expectedExceptionHandler, lastChanceHandler.InnerHandler);
                }
            }
        }
コード例 #2
0
        public void ExceptionHandlerGet_IfUnset_UsesExceptionHandlerFromConfiguration()
        {
            // Arrange
            using (HttpConfiguration configuration = CreateConfiguration())
            {
                IExceptionHandler expectedExceptionHandler = CreateDummyExceptionHandler();
                configuration.Services.Replace(typeof(IExceptionHandler), expectedExceptionHandler);

                using (HttpMessageHandler dispatcher = CreateDummyMessageHandler())
                    using (HttpServer product = new HttpServer(configuration, dispatcher))
                    {
                        // Act
                        IExceptionHandler exceptionHandler = product.ExceptionHandler;

                        // Assert
                        Assert.IsType <LastChanceExceptionHandler>(exceptionHandler);
                        LastChanceExceptionHandler lastChanceHandler = (LastChanceExceptionHandler)exceptionHandler;
                        Assert.Same(expectedExceptionHandler, lastChanceHandler.InnerHandler);
                    }
            }
        }