public void UseAttributesThrows_ArgumentNullException_WhenServiceProviderIsNull()
        {
            var exception = Should.Throw <ArgumentNullException>(() =>
                                                                 DependencyInjectionExtensions.UseAttributes(null));

            exception.ParamName.ShouldBe("serviceProvider");
        }
コード例 #2
0
        public static IWebHost BuildWebHost(string[] args)
        {
            return(new WebHostBuilder()
                   .UseKestrel()
                   .UseContentRoot(Directory.GetCurrentDirectory())
                   .ConfigureAppConfiguration((hostingContext, config) =>
            {
                config.AddJsonFile("appsettings.json", false, false);
                config.AddEnvironmentVariables("MTS_APP_SETTINGS_");
                if (args == null)
                {
                    return;
                }

                config.AddCommandLine(args);
            })
                   .ConfigureLogging((hostingContext, logging) =>
            {
                logging.SetupLogging(DependencyInjectionExtensions.GetConfigurationKeyValueStore(hostingContext.Configuration));
            })
                   .UseDefaultServiceProvider((context, options) => options.ValidateScopes = context.HostingEnvironment.IsDevelopment())
                   .UseStartup <Startup>()
                   .Build());
        }