File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ public static IServiceCollection AddRoutingCore(this IServiceCollection services
4343 {
4444 ArgumentNullException . ThrowIfNull ( services ) ;
4545
46+ // Required for IMeterFactory dependency.
47+ services . AddMetrics ( ) ;
48+
4649 services . TryAddTransient < IInlineConstraintResolver , DefaultInlineConstraintResolver > ( ) ;
4750 services . TryAddTransient < ObjectPoolProvider , DefaultObjectPoolProvider > ( ) ;
4851 services . TryAddSingleton < ObjectPool < UriBuildingContext > > ( s =>
Original file line number Diff line number Diff line change 4646 <Reference Include =" Microsoft.AspNetCore.Http.Features" />
4747 <Reference Include =" Microsoft.AspNetCore.Http.Abstractions" />
4848 <Reference Include =" Microsoft.AspNetCore.Routing.Abstractions" />
49+ <Reference Include =" Microsoft.Extensions.Diagnostics" />
4950 <Reference Include =" Microsoft.Extensions.Features" />
5051 <Reference Include =" Microsoft.Extensions.ObjectPool" />
5152 <Reference Include =" Microsoft.Extensions.Options" />
Original file line number Diff line number Diff line change 1010using Microsoft . AspNetCore . Routing . Matching ;
1111using Microsoft . AspNetCore . Routing . TestObjects ;
1212using Microsoft . AspNetCore . Testing ;
13+ using Microsoft . Extensions . DependencyInjection ;
1314using Microsoft . Extensions . Logging ;
1415using Microsoft . Extensions . Logging . Abstractions ;
1516using Microsoft . Extensions . Logging . Testing ;
@@ -393,6 +394,36 @@ public async Task Endpoint_HasBodySizeFeature_SetUsingSizeLimitMetadata(bool isR
393394 Assert . Equal ( expectedRequestSizeLimit , actualRequestSizeLimit ) ;
394395 }
395396
397+ [ Fact ]
398+ public async Task Create_WithoutHostBuilder_Success ( )
399+ {
400+ // Arrange
401+ var httpContext = CreateHttpContext ( ) ;
402+
403+ var services = new ServiceCollection ( ) ;
404+ services . AddLogging ( ) ;
405+ services . AddOptions ( ) ;
406+ services . AddSingleton < DiagnosticListener > ( s => new DiagnosticListener ( "Test" ) ) ;
407+ services . AddRouting ( ) ;
408+
409+ var applicationBuilder = new ApplicationBuilder ( services . BuildServiceProvider ( ) ) ;
410+
411+ applicationBuilder . UseRouting ( ) ;
412+ applicationBuilder . UseEndpoints ( endpoints =>
413+ {
414+ endpoints . MapGet ( "/" , ( HttpContext c ) => Task . CompletedTask ) ;
415+ } ) ;
416+
417+ var requestDelegate = applicationBuilder . Build ( ) ;
418+
419+ // Act
420+ await requestDelegate ( httpContext ) ;
421+
422+ // Assert
423+ var endpointFeature = httpContext . Features . Get < IEndpointFeature > ( ) ;
424+ Assert . NotNull ( endpointFeature ) ;
425+ }
426+
396427 private class RequestSizeLimitMetadata ( long ? maxRequestBodySize ) : IRequestSizeLimitMetadata
397428 {
398429
You can’t perform that action at this time.
0 commit comments