Пример #1
0
        public void GetHandlerWithConfiguration_IfConfigurationIsNull_Throws()
        {
            // Arrange
            HttpConfiguration configuration = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => ExceptionServices.GetHandler(configuration), "configuration");
        }
Пример #2
0
        public void GetHandlerWithServices_IfServicesIsNull_Throws()
        {
            // Arrange
            ServicesContainer services = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => ExceptionServices.GetHandler(services), "services");
        }
Пример #3
0
        public void GetHandlerWithServices_ReturnsLastChanceHandlerWithServicesInnerHandler()
        {
            // Arrange
            IExceptionHandler expectedHandler = CreateDummyHandler();

            using (ServicesContainer services = CreateServices(expectedHandler))
            {
                // Act
                IExceptionHandler handler = ExceptionServices.GetHandler(services);

                // Assert
                IExceptionHandler innerHandler = Assert.IsType <LastChanceExceptionHandler>(handler).InnerHandler;
                Assert.Same(expectedHandler, innerHandler);
            }
        }
Пример #4
0
        public void GetHandlerWithConfiguration_ReturnsLastChanceHandlerWithServicesInnerHandler()
        {
            // Arrange
            IExceptionHandler expectedHandler = CreateDummyHandler();

            using (HttpConfiguration configuration = CreateConfiguration(expectedHandler))
            {
                // Act
                IExceptionHandler handler = ExceptionServices.GetHandler(configuration);

                // Assert
                IExceptionHandler innerHandler = Assert.IsType <LastChanceExceptionHandler>(handler).InnerHandler;
                Assert.Same(expectedHandler, innerHandler);
            }
        }
Пример #5
0
        public void GetHandlerWithServices_IfHandlerIsAbsent_ReturnsLastChanceHandlerWithEmptyInnerHandler()
        {
            // Arrange
            IExceptionHandler servicesHandler = null;

            using (ServicesContainer services = CreateServices(servicesHandler))
            {
                // Act
                IExceptionHandler handler = ExceptionServices.GetHandler(services);

                // Assert
                IExceptionHandler innerHandler = Assert.IsType <LastChanceExceptionHandler>(handler).InnerHandler;
                Assert.IsType <EmptyExceptionHandler>(innerHandler);
            }
        }
Пример #6
0
        public void GetHandlerWithServices_ReturnsSameInstance()
        {
            // Arrange
            IExceptionHandler innerHandler = CreateDummyHandler();

            using (ServicesContainer services = CreateServices(innerHandler))
            {
                IExceptionHandler firstHandler = ExceptionServices.GetHandler(services);

                // Act
                IExceptionHandler secondHandler = ExceptionServices.GetHandler(services);

                // Assert
                Assert.Same(firstHandler, secondHandler);
            }
        }