Updating test TFMs for custom test discovery

This commit is contained in:
John Luo 2016-02-19 16:51:04 -08:00
parent 8bde9b7e72
commit a9644a5bf3
6 changed files with 16 additions and 38 deletions

View File

@ -16,7 +16,7 @@
},
"imports": "portable-net451+win8"
},
"dnx451": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.Threading.Tasks": ""
@ -29,4 +29,4 @@
"compilationOptions": {
"warningsAsErrors": true
}
}
}

View File

@ -22,7 +22,7 @@
},
"imports": "portable-net451+win8"
},
"dnx451": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.Threading.Tasks": ""
@ -33,4 +33,4 @@
}
}
}
}
}

View File

@ -26,7 +26,6 @@ namespace Microsoft.AspNetCore.Diagnostics.FunctionalTests
using (new CultureReplacer())
{
var builder = new WebHostBuilder()
.ConfigureServices(InitializeServices)
.UseStartup(typeof(TStartup));
_server = new TestServer(builder);
@ -43,31 +42,5 @@ namespace Microsoft.AspNetCore.Diagnostics.FunctionalTests
Client.Dispose();
_server.Dispose();
}
protected virtual void InitializeServices(IServiceCollection services)
{
var libraryManager = DnxPlatformServices.Default.LibraryManager;
// When an application executes in a regular context, the application base path points to the root
// directory where the application is located, for example .../samples/MvcSample.Web. However, when
// executing an application as part of a test, the ApplicationBasePath of the IApplicationEnvironment
// points to the root folder of the test project.
// To compensate, we need to calculate the correct project path and override the application
// environment value so that components like the view engine work properly in the context of the test.
var startupAssembly = typeof(TStartup).GetTypeInfo().Assembly;
var applicationName = startupAssembly.GetName().Name;
var library = libraryManager.GetLibrary(applicationName);
var applicationRoot = Path.GetDirectoryName(library.Path);
var applicationEnvironment = PlatformServices.Default.Application;
services.AddSingleton<IApplicationEnvironment>(
new TestApplicationEnvironment(applicationEnvironment, applicationName, applicationRoot));
// Inject a custom assembly provider. Overrides AddMvc() because that uses TryAdd().
var assemblyProvider = new StaticAssemblyProvider();
assemblyProvider.CandidateAssemblies.Add(startupAssembly);
services.AddSingleton<IAssemblyProvider>(assemblyProvider);
}
}
}

View File

@ -14,7 +14,7 @@
"RuntimeInfoPageSample": "1.0.0",
"StatusCodePagesSample": "1.0.0",
"WelcomePageSample": "1.0.0",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
"xunit": "2.1.0"
},
"exclude": [
"wwwroot",
@ -28,11 +28,16 @@
"dotnet-test-xunit": "1.0.0-dev-*"
}
},
"dnx451": {}
"dnx451": {
"dependencies": {
"xunit.runner.console": "2.1.0"
}
}
},
"testRunner": "xunit",
"publishExclude": [
"**.user",
"**.vspscc"
],
"version": "1.0.0-*"
}
}

View File

@ -21,7 +21,7 @@
},
"imports": "portable-net451+win8"
},
"dnx451": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.Threading.Tasks": ""
@ -39,4 +39,4 @@
"resource": [
"Resources/**"
]
}
}

View File

@ -19,7 +19,7 @@
},
"imports": "portable-net451+win8"
},
"dnx451": {
"net451": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.Threading.Tasks": ""
@ -30,4 +30,4 @@
}
},
"testRunner": "xunit"
}
}