public void CreateHostBuilderTest() { Assert.Null(StartupLoader.CreateHostBuilder(new EmptyStartup(), Name)); Assert.Throws <InvalidOperationException>(() => StartupLoader.CreateHostBuilder(new CreateHostBuilderTestStartup0(), new AssemblyName())); Assert.Throws <InvalidOperationException>(() => StartupLoader.CreateHostBuilder(new CreateHostBuilderTestStartup0(), Name)); object startup = new CreateHostBuilderTestStartup1(); Assert.Equal(startup, StartupLoader.CreateHostBuilder(startup, Name)?.Build().Services.GetService <CreateHostBuilderTestStartup1>()); startup = new CreateHostBuilderTestStartup2(); Assert.Equal(startup, StartupLoader.CreateHostBuilder(startup, Name)?.Build().Services.GetService <CreateHostBuilderTestStartup2>()); Assert.Throws <InvalidOperationException>(() => StartupLoader.CreateHostBuilder(new CreateHostBuilderTestStartup3(), Name)); Assert.Equal(Name, StartupLoader.CreateHostBuilder(new CreateHostBuilderTestStartup4(), Name)?.Build().Services.GetService <AssemblyName>()); Assert.Throws <InvalidOperationException>(() => StartupLoader.CreateHostBuilder(new CreateHostBuilderTestStartup5(), Name)); }