Example #1
0
        public void GetLoggerWithConfiguration_IfConfigurationIsNull_Throws()
        {
            // Arrange
            HttpConfiguration configuration = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => ExceptionServices.GetLogger(configuration), "configuration");
        }
Example #2
0
        public void GetLoggerWithServices_IfServicesIsNull_Throws()
        {
            // Arrange
            ServicesContainer services = null;

            // Act & Assert
            Assert.ThrowsArgumentNull(() => ExceptionServices.GetLogger(services), "services");
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #6
0
        public void GetLoggerWithServices_ReturnsSameInstance()
        {
            // Arrange
            IExceptionLogger innerLogger = CreateDummyLogger();

            using (ServicesContainer services = CreateServices(innerLogger))
            {
                IExceptionLogger firstLogger = ExceptionServices.GetLogger(services);

                // Act
                IExceptionLogger secondLogger = ExceptionServices.GetLogger(services);

                // Assert
                Assert.Same(firstLogger, secondLogger);
            }
        }
Example #7
0
        public void GetLoggerWithConfiguration_ReturnsCompositeExceptionLoggerWithServicesLoggers()
        {
            // Arrange
            IExceptionLogger expectedLogger = CreateDummyLogger();

            using (HttpConfiguration configuration = CreateConfiguration(expectedLogger))
            {
                // Act
                IExceptionLogger logger = ExceptionServices.GetLogger(configuration);

                // Assert
                IEnumerable <IExceptionLogger> loggers = Assert.IsType <CompositeExceptionLogger>(logger).Loggers;
                IExceptionLogger actualLogger          = Assert.Single(loggers);
                Assert.Same(expectedLogger, actualLogger);
            }
        }
Example #8
0
        public void GetLoggerWithServices_ReturnsCompositeExceptionLoggerWithServicesLoggers()
        {
            // Arrange
            IExceptionLogger expectedLogger = CreateDummyLogger();

            using (ServicesContainer services = CreateServices(expectedLogger))
            {
                // Act
                IExceptionLogger logger = ExceptionServices.GetLogger(services);

                // Assert
                IEnumerable <IExceptionLogger> loggers = Assert.IsType <CompositeExceptionLogger>(logger).Loggers;
                IExceptionLogger actualLogger          = Assert.Single(loggers);
                Assert.Same(expectedLogger, actualLogger);
            }
        }