This repository was archived by the owner on Dec 19, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
src/Microsoft.AspNet.TestHost
test/Microsoft.AspNet.TestHost.Tests Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,14 @@ public TestServer(IWebApplicationBuilder builder)
29
29
30
30
public Uri BaseAddress { get ; set ; } = new Uri ( "http://localhost/" ) ;
31
31
32
+ public IWebApplication Application
33
+ {
34
+ get
35
+ {
36
+ return _appInstance ;
37
+ }
38
+ }
39
+
32
40
IFeatureCollection IServer . Features { get ; }
33
41
34
42
public HttpMessageHandler CreateHandler ( )
Original file line number Diff line number Diff line change @@ -31,6 +31,21 @@ public void CreateWithDelegate()
31
31
new TestServer ( new WebApplicationBuilder ( ) . Configure ( app => { } ) ) ;
32
32
}
33
33
34
+ [ Fact ]
35
+ public void ApplicationServicesAvailableFromTestServer ( )
36
+ {
37
+ var testService = new TestService ( ) ;
38
+ var builder = new WebApplicationBuilder ( )
39
+ . Configure ( app => { } )
40
+ . ConfigureServices ( services =>
41
+ {
42
+ services . AddSingleton ( testService ) ;
43
+ } ) ;
44
+ var server = new TestServer ( builder ) ;
45
+
46
+ Assert . Equal ( testService , server . Application . Services . GetRequiredService < TestService > ( ) ) ;
47
+ }
48
+
34
49
[ ConditionalFact ]
35
50
[ FrameworkSkipCondition ( RuntimeFrameworks . Mono , SkipReason = "Hangs randomly (issue #507)" ) ]
36
51
public async Task RequestServicesAutoCreated ( )
You can’t perform that action at this time.
0 commit comments