This repository was archived by the owner on Dec 19, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +43
-4
lines changed
src/Microsoft.AspNet.Hosting
test/Microsoft.AspNet.Hosting.Tests Expand file tree Collapse file tree 3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System . Reflection ;
5
+ using System . Runtime . CompilerServices ;
5
6
6
- [ assembly: AssemblyMetadata ( "Serviceable" , "True" ) ]
7
+ [ assembly: AssemblyMetadata ( "Serviceable" , "True" ) ]
8
+ [ assembly: InternalsVisibleTo ( "Microsoft.AspNet.Hosting.Tests" ) ]
Original file line number Diff line number Diff line change @@ -42,8 +42,10 @@ public class WebHostBuilder
42
42
private string _serverFactoryLocation ;
43
43
private IServerFactory _serverFactory ;
44
44
45
- public WebHostBuilder ( [ NotNull ] IServiceProvider services )
46
- : this ( services , config : new ConfigurationBuilder ( ) . Build ( ) ) { }
45
+ public WebHostBuilder ( [ NotNull ] IServiceProvider services )
46
+ : this ( services , config : new ConfigurationBuilder ( ) . Build ( ) )
47
+ {
48
+ }
47
49
48
50
public WebHostBuilder ( [ NotNull ] IServiceProvider services , [ NotNull ] IConfiguration config )
49
51
{
@@ -177,7 +179,8 @@ public WebHostBuilder UseStartup([NotNull] Action<IApplicationBuilder> configure
177
179
public WebHostBuilder UseStartup ( [ NotNull ] Action < IApplicationBuilder > configureApp , Action < IServiceCollection > configureServices )
178
180
{
179
181
_startup = new StartupMethods ( configureApp ,
180
- services => {
182
+ services =>
183
+ {
181
184
if ( configureServices != null )
182
185
{
183
186
configureServices ( services ) ;
Original file line number Diff line number Diff line change
1
+ // Copyright (c) .NET Foundation. All rights reserved.
2
+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
+
4
+ using Microsoft . AspNet . Hosting . Internal ;
5
+ using Microsoft . Framework . Runtime . Infrastructure ;
6
+ using Xunit ;
7
+
8
+ namespace Microsoft . AspNet . Hosting
9
+ {
10
+ public class WebHostBuilderTests
11
+ {
12
+ [ Fact ]
13
+ public void Build_uses_application_for_startup_assembly_by_default ( )
14
+ {
15
+ var builder = CreateWebHostBuilder ( ) ;
16
+
17
+ var engine = ( HostingEngine ) builder . Build ( ) ;
18
+
19
+ Assert . Equal ( "Microsoft.AspNet.Hosting.Tests" , engine . StartupAssemblyName ) ;
20
+ }
21
+
22
+ [ Fact ]
23
+ public void Build_honors_UseStartup_with_string ( )
24
+ {
25
+ var builder = CreateWebHostBuilder ( ) ;
26
+
27
+ var engine = ( HostingEngine ) builder . UseStartup ( "MyStartupAssembly" ) . Build ( ) ;
28
+
29
+ Assert . Equal ( "MyStartupAssembly" , engine . StartupAssemblyName ) ;
30
+ }
31
+
32
+ private WebHostBuilder CreateWebHostBuilder ( ) => new WebHostBuilder ( CallContextServiceLocator . Locator . ServiceProvider ) ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments