Skip to content

Commit 58b9f9b

Browse files
committed
Add test
1 parent b32867c commit 58b9f9b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Http/Routing/test/UnitTests/EndpointRoutingMiddlewareTest.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.AspNetCore.Routing.Matching;
1111
using Microsoft.AspNetCore.Routing.TestObjects;
1212
using Microsoft.AspNetCore.Testing;
13+
using Microsoft.Extensions.DependencyInjection;
1314
using Microsoft.Extensions.Logging;
1415
using Microsoft.Extensions.Logging.Abstractions;
1516
using 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

0 commit comments

Comments
 (0)