10
10
using Microsoft . AspNetCore . Http . Features ;
11
11
using Microsoft . AspNetCore . Routing ;
12
12
13
+ /// <summary>
14
+ /// Mocked <see cref="IApplicationBuilder"/>. Used for extracting registered routes.
15
+ /// </summary>
13
16
public class MockedApplicationBuilder : IApplicationBuilder
14
17
{
15
18
private const string ServerFeaturesPropertyName = "server.Features" ;
16
19
private const string ApplicationServicesPropertyName = "application.Services" ;
17
20
18
21
private readonly IList < Func < RequestDelegate , RequestDelegate > > components = new List < Func < RequestDelegate , RequestDelegate > > ( ) ;
19
22
23
+ /// <summary>
24
+ /// Initializes a new instance of the <see cref="MockedApplicationBuilder"/> class.
25
+ /// </summary>
26
+ /// <param name="serviceProvider">Application service provider.</param>
20
27
public MockedApplicationBuilder ( IServiceProvider serviceProvider )
21
28
{
22
29
this . Properties = new Dictionary < string , object > ( ) ;
23
30
this . Routes = new RouteCollection ( ) ;
24
31
this . ApplicationServices = serviceProvider ;
25
32
}
26
33
34
+ /// <summary>
35
+ /// Initializes a new instance of the <see cref="MockedApplicationBuilder"/> class.
36
+ /// </summary>
37
+ /// <param name="builder">Application builder to copy properties from.</param>
27
38
public MockedApplicationBuilder ( IApplicationBuilder builder )
28
39
{
29
40
this . Properties = builder . Properties ;
30
41
}
31
-
42
+
43
+ /// <summary>
44
+ /// Gets or sets the current application services.
45
+ /// </summary>
46
+ /// <value>Result of <see cref="IServiceProvider"/> type.</value>
32
47
public IServiceProvider ApplicationServices
33
48
{
34
49
get
@@ -42,6 +57,10 @@ public IServiceProvider ApplicationServices
42
57
}
43
58
}
44
59
60
+ /// <summary>
61
+ /// Gets the current server feature collection. Not used in the actual testing.
62
+ /// </summary>
63
+ /// <value>Result of <see cref="IFeatureCollection"/> type.</value>
45
64
public IFeatureCollection ServerFeatures
46
65
{
47
66
get
@@ -50,10 +69,23 @@ public IFeatureCollection ServerFeatures
50
69
}
51
70
}
52
71
72
+ /// <summary>
73
+ /// Gets the current application properties. Not used in the actual testing.
74
+ /// </summary>
75
+ /// <value>Result of <see cref="IFeatureCollection"/> type.</value>
53
76
public IDictionary < string , object > Properties { get ; }
54
77
78
+ /// <summary>
79
+ /// Gets the registered route collection.
80
+ /// </summary>
81
+ /// <value>Result of <see cref="RouteCollection"/> type.</value>
55
82
public RouteCollection Routes { get ; set ; }
56
83
84
+ /// <summary>
85
+ /// Extracts registered routes from the provided middleware, if such are found.
86
+ /// </summary>
87
+ /// <param name="middleware">Middleware delegate.</param>
88
+ /// <returns>The same <see cref="IApplicationBuilder"/>.</returns>
57
89
public IApplicationBuilder Use ( Func < RequestDelegate , RequestDelegate > middleware )
58
90
{
59
91
this . ExtractRoutes ( middleware ) ;
@@ -62,11 +94,19 @@ public IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware
62
94
return this ;
63
95
}
64
96
97
+ /// <summary>
98
+ /// Returns new instance of <see cref="IApplicationBuilder"/>. Not used in the actual testing.
99
+ /// </summary>
100
+ /// <returns>Result of <see cref="IApplicationBuilder"/> type.</returns>
65
101
public IApplicationBuilder New ( )
66
102
{
67
103
return new MockedApplicationBuilder ( this ) ;
68
104
}
69
105
106
+ /// <summary>
107
+ /// Builds the application delegate, which will process the incoming HTTP requests. Not used in the actual testing.
108
+ /// </summary>
109
+ /// <returns>Result of <see cref="RequestDelegate"/> type.</returns>
70
110
public RequestDelegate Build ( )
71
111
{
72
112
RequestDelegate app = context =>
0 commit comments