Skip to content
代码片段 群组 项目
未验证 提交 a0193e2f 编辑于 作者: Safia Abdalla's avatar Safia Abdalla 提交者: GitHub
浏览文件

Set route name metadata in WithName (#35388)

上级 5393e1f2
No related branches found
No related tags found
无相关合并请求
......@@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Builder
/// <returns>The <see cref="IEndpointConventionBuilder"/>.</returns>
public static TBuilder WithName<TBuilder>(this TBuilder builder, string endpointName) where TBuilder : IEndpointConventionBuilder
{
builder.WithMetadata(new EndpointNameAttribute(endpointName));
builder.WithMetadata(new EndpointNameAttribute(endpointName), new RouteNameMetadata(endpointName));
return builder;
}
......
......@@ -119,16 +119,20 @@ namespace Microsoft.AspNetCore.Builder
public void WithName_SetsEndpointName()
{
// Arrange
var name = "SomeEndpointName";
var builder = CreateBuilder();
// Act
builder.WithName("SomeEndpointName");
builder.WithName(name);
// Assert
var endpoint = builder.Build();
var endpointName = endpoint.Metadata.GetMetadata<IEndpointNameMetadata>();
Assert.Equal("SomeEndpointName", endpointName.EndpointName);
Assert.Equal(name, endpointName.EndpointName);
var routeName = endpoint.Metadata.GetMetadata<IRouteNameMetadata>();
Assert.Equal(name, routeName.RouteName);
}
[Fact]
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册