From 5cf3d9ab11231678f85c09c70e5a4d9cb87631bd Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Mon, 15 May 2017 14:44:17 -0700 Subject: [PATCH] Upgrade test framework versions and fix test issues --- build/dependencies.props | 4 +-- ....AspNetCore.Hosting.FunctionalTests.csproj | 4 --- .../Microsoft.AspNetCore.Hosting.Tests.csproj | 4 --- .../StartupManagerTests.cs | 30 +++++++++++-------- .../WebHostBuilderTests.cs | 2 +- ...Microsoft.AspNetCore.TestHost.Tests.csproj | 4 --- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index df91a8d97b..98f4d1a3e7 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,9 +3,9 @@ 2.0.0-* 2.1.0-* $(BundledNETStandardPackageVersion) - 15.0.0 + 15.3.0-* 1.0.1 - 2.2.0 + 2.3.0-beta2-* 1.4.0 3.2.0 diff --git a/test/Microsoft.AspNetCore.Hosting.FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj b/test/Microsoft.AspNetCore.Hosting.FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj index 78b9e54fcc..ee55cd9f6e 100644 --- a/test/Microsoft.AspNetCore.Hosting.FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.Hosting.FunctionalTests/Microsoft.AspNetCore.Hosting.FunctionalTests.csproj @@ -22,8 +22,4 @@ - - - - diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/Microsoft.AspNetCore.Hosting.Tests.csproj b/test/Microsoft.AspNetCore.Hosting.Tests/Microsoft.AspNetCore.Hosting.Tests.csproj index 96de8da94f..8b3a08da12 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/Microsoft.AspNetCore.Hosting.Tests.csproj +++ b/test/Microsoft.AspNetCore.Hosting.Tests/Microsoft.AspNetCore.Hosting.Tests.csproj @@ -25,8 +25,4 @@ - - - - diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs index 62e8f5bda9..31ba1c9062 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/StartupManagerTests.cs @@ -15,16 +15,15 @@ using Xunit; namespace Microsoft.AspNetCore.Hosting.Tests { - public class StartupManagerTests : IFakeStartupCallback + public class StartupManagerTests { - private readonly IList _configurationMethodCalledList = new List(); - [Fact] public void StartupClassMayHaveHostingServicesInjected() { + var callbackStartup = new FakeStartupCallback(); var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton, DefaultServiceProviderFactory>(); - serviceCollection.AddSingleton(this); + serviceCollection.AddSingleton(callbackStartup); var services = serviceCollection.BuildServiceProvider(); var type = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "WithServices"); @@ -34,7 +33,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests app.ApplicationServices = startup.ConfigureServicesDelegate(serviceCollection); startup.ConfigureDelegate(app); - Assert.Equal(2, _configurationMethodCalledList.Count); + Assert.Equal(2, callbackStartup.MethodsCalled); } [Theory] @@ -69,7 +68,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests { var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton, DefaultServiceProviderFactory>(); - serviceCollection.AddSingleton(this); + serviceCollection.AddSingleton(new FakeStartupCallback()); var services = serviceCollection.BuildServiceProvider(); var type = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "Boom"); var ex = Assert.Throws(() => StartupLoader.LoadMethods(services, type, "Boom")); @@ -81,7 +80,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests { var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton, DefaultServiceProviderFactory>(); - serviceCollection.AddSingleton(this); + serviceCollection.AddSingleton(new FakeStartupCallback()); var services = serviceCollection.BuildServiceProvider(); var type = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "TwoConfigures"); @@ -95,7 +94,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests { var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton, DefaultServiceProviderFactory>(); - serviceCollection.AddSingleton(this); + serviceCollection.AddSingleton(new FakeStartupCallback()); var services = serviceCollection.BuildServiceProvider(); var diagnosticMessages = new List(); @@ -110,7 +109,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests { var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton, DefaultServiceProviderFactory>(); - serviceCollection.AddSingleton(this); + serviceCollection.AddSingleton(new FakeStartupCallback()); var services = serviceCollection.BuildServiceProvider(); var type = StartupLoader.FindStartupType("Microsoft.AspNetCore.Hosting.Tests", "TwoConfigureServices"); @@ -395,9 +394,16 @@ namespace Microsoft.AspNetCore.Hosting.Tests } } - public void ConfigurationMethodCalled(object instance) + public class FakeStartupCallback : IFakeStartupCallback { - _configurationMethodCalledList.Add(instance); + private readonly IList _configurationMethodCalledList = new List(); + + public int MethodsCalled => _configurationMethodCalledList.Count; + + public void ConfigurationMethodCalled(object instance) + { + _configurationMethodCalledList.Add(instance); + } } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs index 0853f75049..1e51be3850 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs @@ -837,7 +837,7 @@ namespace Microsoft.AspNetCore.Hosting .UseStartup() .Build()) { } - Assert.Equal(false, factory.Disposed); + Assert.False(factory.Disposed); } [Fact] diff --git a/test/Microsoft.AspNetCore.TestHost.Tests/Microsoft.AspNetCore.TestHost.Tests.csproj b/test/Microsoft.AspNetCore.TestHost.Tests/Microsoft.AspNetCore.TestHost.Tests.csproj index a9423120c4..792dbe7aec 100644 --- a/test/Microsoft.AspNetCore.TestHost.Tests/Microsoft.AspNetCore.TestHost.Tests.csproj +++ b/test/Microsoft.AspNetCore.TestHost.Tests/Microsoft.AspNetCore.TestHost.Tests.csproj @@ -18,8 +18,4 @@ - - - -