Making application available from TestServer #519
This commit is contained in:
parent
6ff83dddfe
commit
48451bdabc
|
|
@ -29,6 +29,14 @@ namespace Microsoft.AspNet.TestHost
|
||||||
|
|
||||||
public Uri BaseAddress { get; set; } = new Uri("http://localhost/");
|
public Uri BaseAddress { get; set; } = new Uri("http://localhost/");
|
||||||
|
|
||||||
|
public IWebApplication Application
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _appInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IFeatureCollection IServer.Features { get; }
|
IFeatureCollection IServer.Features { get; }
|
||||||
|
|
||||||
public HttpMessageHandler CreateHandler()
|
public HttpMessageHandler CreateHandler()
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,21 @@ namespace Microsoft.AspNet.TestHost
|
||||||
new TestServer(new WebApplicationBuilder().Configure(app => { }));
|
new TestServer(new WebApplicationBuilder().Configure(app => { }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ApplicationServicesAvailableFromTestServer()
|
||||||
|
{
|
||||||
|
var testService = new TestService();
|
||||||
|
var builder = new WebApplicationBuilder()
|
||||||
|
.Configure(app => { })
|
||||||
|
.ConfigureServices(services =>
|
||||||
|
{
|
||||||
|
services.AddSingleton(testService);
|
||||||
|
});
|
||||||
|
var server = new TestServer(builder);
|
||||||
|
|
||||||
|
Assert.Equal(testService, server.Application.Services.GetRequiredService<TestService>());
|
||||||
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono, SkipReason = "Hangs randomly (issue #507)")]
|
[FrameworkSkipCondition(RuntimeFrameworks.Mono, SkipReason = "Hangs randomly (issue #507)")]
|
||||||
public async Task RequestServicesAutoCreated()
|
public async Task RequestServicesAutoCreated()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue