Exemplo n.º 1
0
        public void GetLoggerWithConfiguration_IfConfigurationIsNull_Throws()
        {
            // Arrange
            HttpConfiguration configuration = null;

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

            // Act & Assert
            Assert.ThrowsArgumentNull(() => ExceptionServices.GetLogger(services), "services");
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }