示例#1
0
        public void can_bootstrap_a_host()
        {
            var input = new AspNetCoreInput
            {
                WebHostBuilder = new WebHostBuilder()
                                 .UseServer(new NulloServer())
                                 .UseStartup <EmptyStartup>()
            };

            using (var host = input.BuildHost())
            {
                host.ShouldNotBeNull();
            }
        }
示例#2
0
        public void modify_the_environment()
        {
            var input = new AspNetCoreInput
            {
                WebHostBuilder = new WebHostBuilder()
                                 .UseServer(new NulloServer())
                                 .UseStartup <EmptyStartup>(),
                EnvironmentFlag = "Weird"
            };

            using (var host = input.BuildHost())
            {
                host.Services.GetRequiredService <IHostingEnvironment>()
                .EnvironmentName.ShouldBe("Weird");
            }
        }
示例#3
0
        public void modify_configuration_items()
        {
            var input = new AspNetCoreInput
            {
                WebHostBuilder = new WebHostBuilder()
                                 .UseServer(new NulloServer())
                                 .UseStartup <EmptyStartup>(),
                ConfigFlag = new Dictionary <string, string> {
                    { "direction", "south" }, { "color", "orange" }
                }
            };

            using (var host = input.BuildHost())
            {
                var config = host.Services.GetRequiredService <IConfiguration>();

                config["direction"].ShouldBe("south");
                config["color"].ShouldBe("orange");
            }
        }