@@ -21,30 +21,7 @@ namespace Microsoft.AspNetCore.Routing
21
21
public class EndpointRoutingMiddlewareTest
22
22
{
23
23
[ Fact ]
24
- public async Task Invoke_OnException_ResetsEndpoint ( )
25
- {
26
- // Arrange
27
- var httpContext = CreateHttpContext ( ) ;
28
-
29
- var middleware = CreateMiddleware ( next : context => throw new Exception ( ) ) ;
30
-
31
- // Act
32
- try
33
- {
34
- await middleware . Invoke ( httpContext ) ;
35
- }
36
- catch
37
- {
38
- // Do nothing, we expect the test to throw.
39
- }
40
-
41
- // Assert
42
- var endpoint = httpContext . GetEndpoint ( ) ;
43
- Assert . Null ( endpoint ) ;
44
- }
45
-
46
- [ Fact ]
47
- public async Task Invoke_OnCall_SetsEndpointFeatureAndResetsEndpoint ( )
24
+ public async Task Invoke_OnCall_SetsEndpointFeature ( )
48
25
{
49
26
// Arrange
50
27
var httpContext = CreateHttpContext ( ) ;
@@ -57,16 +34,14 @@ public async Task Invoke_OnCall_SetsEndpointFeatureAndResetsEndpoint()
57
34
// Assert
58
35
var endpointFeature = httpContext . Features . Get < IEndpointFeature > ( ) ;
59
36
Assert . NotNull ( endpointFeature ) ;
60
- Assert . Null ( endpointFeature . Endpoint ) ;
61
37
}
62
38
63
39
[ Fact ]
64
- public async Task Invoke_SkipsRoutingAndMaintainsEndpoint_IfEndpointSet ( )
40
+ public async Task Invoke_SkipsRouting_IfEndpointSet ( )
65
41
{
66
42
// Arrange
67
43
var httpContext = CreateHttpContext ( ) ;
68
- var expectedEndpoint = new Endpoint ( c => Task . CompletedTask , new EndpointMetadataCollection ( ) , "myapp" ) ;
69
- httpContext . SetEndpoint ( expectedEndpoint ) ;
44
+ httpContext . SetEndpoint ( new Endpoint ( c => Task . CompletedTask , new EndpointMetadataCollection ( ) , "myapp" ) ) ;
70
45
71
46
var middleware = CreateMiddleware ( ) ;
72
47
@@ -75,7 +50,7 @@ public async Task Invoke_SkipsRoutingAndMaintainsEndpoint_IfEndpointSet()
75
50
76
51
// Assert
77
52
var endpoint = httpContext . GetEndpoint ( ) ;
78
- Assert . Same ( expectedEndpoint , endpoint ) ;
53
+ Assert . NotNull ( endpoint ) ;
79
54
Assert . Equal ( "myapp" , endpoint . DisplayName ) ;
80
55
}
81
56
0 commit comments