|
12 | 12 | using Microsoft.AspNetCore.Routing;
|
13 | 13 | using Microsoft.AspNetCore.Routing.Patterns;
|
14 | 14 | using Microsoft.Extensions.DependencyInjection;
|
| 15 | +using Microsoft.Extensions.FileProviders; |
| 16 | +using Microsoft.Extensions.Hosting; |
15 | 17 | using Xunit;
|
16 | 18 |
|
17 | 19 | namespace Microsoft.AspNetCore.Mvc.ApiExplorer
|
@@ -44,11 +46,11 @@ public void UsesDeclaringTypeAsControllerName()
|
44 | 46 | }
|
45 | 47 |
|
46 | 48 | [Fact]
|
47 |
| - public void UsesMapAsControllerNameIfNoDeclaringType() |
| 49 | + public void UsesApplicationNameAsControllerNameIfNoDeclaringType() |
48 | 50 | {
|
49 | 51 | var apiDescription = GetApiDescription(() => { });
|
50 | 52 |
|
51 |
| - Assert.Equal("Map", apiDescription.ActionDescriptor.RouteValues["controller"]); |
| 53 | + Assert.Equal(nameof(EndpointMetadataApiDescriptionProviderTest), apiDescription.ActionDescriptor.RouteValues["controller"]); |
52 | 54 | }
|
53 | 55 |
|
54 | 56 | [Fact]
|
@@ -324,8 +326,12 @@ private IList<ApiDescription> GetApiDescriptions(
|
324 | 326 |
|
325 | 327 | var endpoint = new RouteEndpoint(httpContext => Task.CompletedTask, routePattern, 0, endpointMetadata, null);
|
326 | 328 | var endpointDataSource = new DefaultEndpointDataSource(endpoint);
|
| 329 | + var hostEnvironment = new HostEnvironment |
| 330 | + { |
| 331 | + ApplicationName = nameof(EndpointMetadataApiDescriptionProviderTest) |
| 332 | + }; |
327 | 333 |
|
328 |
| - var provider = new EndpointMetadataApiDescriptionProvider(endpointDataSource, new ServiceProviderIsService()); |
| 334 | + var provider = new EndpointMetadataApiDescriptionProvider(endpointDataSource, hostEnvironment, new ServiceProviderIsService()); |
329 | 335 |
|
330 | 336 | provider.OnProvidersExecuting(context);
|
331 | 337 | provider.OnProvidersExecuted(context);
|
@@ -360,5 +366,13 @@ private class ServiceProviderIsService : IServiceProviderIsService
|
360 | 366 | {
|
361 | 367 | public bool IsService(Type serviceType) => serviceType == typeof(IInferredServiceInterface);
|
362 | 368 | }
|
| 369 | + |
| 370 | + private class HostEnvironment : IHostEnvironment |
| 371 | + { |
| 372 | + public string EnvironmentName { get; set; } |
| 373 | + public string ApplicationName { get; set; } |
| 374 | + public string ContentRootPath { get; set; } |
| 375 | + public IFileProvider ContentRootFileProvider { get; set; } |
| 376 | + } |
363 | 377 | }
|
364 | 378 | }
|
0 commit comments