public void AddSejil_registeres_required_services()
        {
            // Arrange
            var webhostBuilder = new WebHostBuilder()
                                 .Configure(app => { })
                                 .ConfigureServices(services =>
                                                    services.AddSingleton <IServer>(Mock.Of <IServer>()));

            // Act
            webhostBuilder.AddSejil("/sejil", LogLevel.Debug);

            // Assert
            var webhost = webhostBuilder.Build();

            using (var scope = webhost.Services.CreateScope())
            {
                var settings    = scope.ServiceProvider.GetService(typeof(ISejilSettings));
                var repository  = scope.ServiceProvider.GetService(typeof(ISejilRepository));
                var sqlProvider = scope.ServiceProvider.GetService(typeof(ISejilSqlProvider));
                var controller  = scope.ServiceProvider.GetService(typeof(ISejilController));

                Assert.NotNull(settings);
                Assert.NotNull(repository);
                Assert.NotNull(sqlProvider);
                Assert.NotNull(controller);
            }
        }
        public void AddSejil_throws_when_none_is_passed_for_log_level()
        {
            // Arrange
            var webhostBuilder = new WebHostBuilder()
                                 .Configure(app => { })
                                 .ConfigureServices(services => services.AddSingleton <IServer>(Mock.Of <IServer>()));

            // Act & assert
            var ex = Assert.Throws <InvalidOperationException>(() => webhostBuilder.AddSejil("/sejil", LogLevel.None));

            Assert.Equal("Minimum log level cannot be set to None.", ex.Message);
        }
        public void AddSejil_sets_intial_settings(LogLevel logLevel, LogEventLevel expectedMappedLogLevel)
        {
            // Arrange
            var url            = "/sejil";
            var webhostBuilder = new WebHostBuilder()
                                 .Configure(app => { })
                                 .ConfigureServices(services => services.AddSingleton <IServer>(Mock.Of <IServer>()));

            // Act
            webhostBuilder.AddSejil(url, logLevel);

            // Assert
            var settings = webhostBuilder.Build().Services.GetRequiredService <ISejilSettings>();

            Assert.Equal(url, settings.Url);
            Assert.Equal(expectedMappedLogLevel, settings.LoggingLevelSwitch.MinimumLevel);
        }