예제 #1
0
        public void ConfigureHostTest()
        {
            var hostBuilder = new HostBuilder();

            StartupLoader.ConfigureHost(hostBuilder, new EmptyStartup());

            Assert.Throws <InvalidOperationException>(() => StartupLoader.ConfigureHost(hostBuilder, new ConfigureHostTestStartup0()));

            StartupLoader.ConfigureHost(hostBuilder, new ConfigureHostTestStartup1());

            Assert.Throws <InvalidOperationException>(() => StartupLoader.ConfigureHost(hostBuilder, new ConfigureHostTestStartup2()));

            Assert.Throws <InvalidOperationException>(() => StartupLoader.ConfigureHost(hostBuilder, new ConfigureHostTestStartup3()));

            Assert.Throws <InvalidOperationException>(() => StartupLoader.ConfigureHost(hostBuilder, new ConfigureHostTestStartup4()));

            Assert.Throws <InvalidOperationException>(() => StartupLoader.ConfigureHost(hostBuilder, new ConfigureHostTestStartup7()));

            var services = hostBuilder.Build().Services;

            Assert.NotNull(services.GetService <ConfigureHostTestStartup1>());
        }