diff --git a/src/Microsoft.AspNet.TestHost/TestServer.cs b/src/Microsoft.AspNet.TestHost/TestServer.cs index 16684a4bd8..48f1679f05 100644 --- a/src/Microsoft.AspNet.TestHost/TestServer.cs +++ b/src/Microsoft.AspNet.TestHost/TestServer.cs @@ -57,13 +57,13 @@ namespace Microsoft.AspNet.TestHost var disposable = engine.Start(hostContext); } - public static TestServer Create(IServiceProvider provider) - { - var startupLoader = new StartupLoader(provider, new NullStartupLoader()); - var name = typeof(TStartup).AssemblyQualifiedName; - var diagnosticMessages = new List(); - return Create(provider, startupLoader.LoadStartup(name, diagnosticMessages)); - } + //public static TestServer Create(IServiceProvider provider) + //{ + // var startupLoader = new StartupLoader(provider, new NullStartupLoader()); + // var name = typeof(TStartup).AssemblyQualifiedName; + // var diagnosticMessages = new List(); + // return Create(provider, startupLoader.LoadStartup(name, "Test", diagnosticMessages)); + //} public static TestServer Create(IServiceProvider provider, Action app) { diff --git a/test/Microsoft.AspNet.Hosting.Tests/Fakes/FakeStartup.cs b/test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs similarity index 87% rename from test/Microsoft.AspNet.Hosting.Tests/Fakes/FakeStartup.cs rename to test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs index 1df444a0af..da91cbeca0 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/Fakes/FakeStartup.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/Fakes/Startup.cs @@ -20,9 +20,13 @@ using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Hosting.Fakes { - public class FakeStartup + public class Startup { - public void Configuration(IBuilder builder) + public Startup() + { + } + + public void Configure(IBuilder builder) { } } diff --git a/test/Microsoft.AspNet.Hosting.Tests/Fakes/FakeStartupWithServices.cs b/test/Microsoft.AspNet.Hosting.Tests/Fakes/StartupWithServices.cs similarity index 79% rename from test/Microsoft.AspNet.Hosting.Tests/Fakes/FakeStartupWithServices.cs rename to test/Microsoft.AspNet.Hosting.Tests/Fakes/StartupWithServices.cs index 2150b21ea7..166b4ff5c5 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/Fakes/FakeStartupWithServices.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/Fakes/StartupWithServices.cs @@ -20,18 +20,19 @@ using Microsoft.AspNet.Http; namespace Microsoft.AspNet.Hosting.Fakes { - public class FakeStartupWithServices + public class StartupWithServices { private readonly IFakeStartupCallback _fakeStartupCallback; - public FakeStartupWithServices(IFakeStartupCallback fakeStartupCallback) + public StartupWithServices(IFakeStartupCallback fakeStartupCallback) { _fakeStartupCallback = fakeStartupCallback; } - public void Configuration(IBuilder builder) + public void Configure(IBuilder builder, IFakeStartupCallback fakeStartupCallback2) { _fakeStartupCallback.ConfigurationMethodCalled(this); + fakeStartupCallback2.ConfigurationMethodCalled(this); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs b/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs index 5491f92de9..d6cbf86841 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/HostingEngineTests.cs @@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Hosting var context = new HostingContext { ServerFactory = this, - ApplicationName = "Microsoft.AspNet.Hosting.Fakes.FakeStartup, Microsoft.AspNet.Hosting.Tests" + ApplicationName = "Microsoft.AspNet.Hosting.Tests" }; var engineStart = engine.Start(context); diff --git a/test/Microsoft.AspNet.Hosting.Tests/Microsoft.AspNet.Hosting.Tests.kproj b/test/Microsoft.AspNet.Hosting.Tests/Microsoft.AspNet.Hosting.Tests.kproj index 48a9989141..65a7bd78f0 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/Microsoft.AspNet.Hosting.Tests.kproj +++ b/test/Microsoft.AspNet.Hosting.Tests/Microsoft.AspNet.Hosting.Tests.kproj @@ -21,7 +21,6 @@ - diff --git a/test/Microsoft.AspNet.Hosting.Tests/StartupManagerTests.cs b/test/Microsoft.AspNet.Hosting.Tests/StartupManagerTests.cs index b04aef9e4c..6684a56205 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/StartupManagerTests.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/StartupManagerTests.cs @@ -29,21 +29,6 @@ namespace Microsoft.AspNet.Hosting { private readonly IList _configurationMethodCalledList = new List(); - [Fact] - public void DefaultServicesLocateStartupByNameAndNamespace() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.Add(HostingServices.GetDefaultServices()); - var services = serviceCollection.BuildServiceProvider(); - - var manager = services.GetService(); - - var startup = manager.LoadStartup("Microsoft.AspNet.Hosting.Fakes.FakeStartup, Microsoft.AspNet.Hosting.Tests"); - - Assert.IsType(manager); - Assert.NotNull(startup); - } - [Fact] public void StartupClassMayHaveHostingServicesInjected() { @@ -54,11 +39,11 @@ namespace Microsoft.AspNet.Hosting var manager = services.GetService(); - var startup = manager.LoadStartup("Microsoft.AspNet.Hosting.Fakes.FakeStartupWithServices, Microsoft.AspNet.Hosting.Tests"); + var startup = manager.LoadStartup("Microsoft.AspNet.Hosting.Tests", "WithServices"); startup.Invoke(null); - Assert.Equal(1, _configurationMethodCalledList.Count); + Assert.Equal(2, _configurationMethodCalledList.Count); } public void ConfigurationMethodCalled(object instance) diff --git a/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs b/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs index f2a2f436a1..c1b0ea1fb3 100644 --- a/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs +++ b/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs @@ -40,23 +40,23 @@ namespace Microsoft.AspNet.TestHost.Tests Assert.DoesNotThrow(() => TestServer.Create(services, app => { })); } - [Fact] - public async Task CreateWithGeneric() - { - // Arrange - var services = new ServiceCollection() - .AddSingleton() - .BuildServiceProvider(); + //[Fact] + //public async Task CreateWithGeneric() + //{ + // // Arrange + // var services = new ServiceCollection() + // .AddSingleton() + // .BuildServiceProvider(); - var server = TestServer.Create(services); - var client = server.Handler; + // var server = TestServer.Create(services); + // var client = server.Handler; - // Act - var response = await client.GetAsync("http://any"); + // // Act + // var response = await client.GetAsync("http://any"); - // Assert - Assert.Equal("Startup", new StreamReader(response.Body).ReadToEnd()); - } + // // Assert + // Assert.Equal("Startup", new StreamReader(response.Body).ReadToEnd()); + //} [Fact] public void ThrowsIfNoApplicationEnvironmentIsRegisteredWithTheProvider() @@ -68,7 +68,7 @@ namespace Microsoft.AspNet.TestHost.Tests // Act & Assert Assert.Throws( "serviceProvider", - () => TestServer.Create(services)); + () => TestServer.Create(services, new Startup().Configuration)); } public class Startup