|
4 | 4 | using System.Linq.Expressions; |
5 | 5 | using System.Reflection; |
6 | 6 | using System.Security.Claims; |
| 7 | +using Microsoft.AspNetCore.Builder; |
7 | 8 | using Microsoft.AspNetCore.Http; |
8 | 9 | using Microsoft.AspNetCore.Http.Metadata; |
9 | 10 | using Microsoft.AspNetCore.Mvc; |
@@ -50,6 +51,23 @@ public void UsesApplicationNameAsOperationTagsIfNoDeclaringType() |
50 | 51 | Assert.Equal(declaringTypeName, tag.Name); |
51 | 52 | } |
52 | 53 |
|
| 54 | + [Fact] |
| 55 | + public void UsesTagsFromMultipleCallsToWithTags() |
| 56 | + { |
| 57 | + var testBuilder = new TestEndpointConventionBuilder(); |
| 58 | + var routeHandlerBuilder = new RouteHandlerBuilder(new[] { testBuilder }); |
| 59 | + |
| 60 | + routeHandlerBuilder |
| 61 | + .WithTags("A") |
| 62 | + .WithTags("B"); |
| 63 | + |
| 64 | + var operation = GetOpenApiOperation(() => { }, additionalMetadata: testBuilder.Metadata.ToArray()); |
| 65 | + |
| 66 | + Assert.Collection(operation.Tags, |
| 67 | + tag => Assert.Equal("A", tag.Name), |
| 68 | + tag => Assert.Equal("B", tag.Name)); |
| 69 | + } |
| 70 | + |
53 | 71 | [Fact] |
54 | 72 | public void ThrowsInvalidOperationExceptionGivenUnnamedParameter() |
55 | 73 | { |
@@ -923,4 +941,17 @@ private struct ArgumentListStruct |
923 | 941 | public InferredJsonClass FromBody { get; set; } |
924 | 942 | public HttpContext Context { get; set; } |
925 | 943 | } |
| 944 | + |
| 945 | + private class TestEndpointConventionBuilder : EndpointBuilder, IEndpointConventionBuilder |
| 946 | + { |
| 947 | + public void Add(Action<EndpointBuilder> convention) |
| 948 | + { |
| 949 | + convention(this); |
| 950 | + } |
| 951 | + |
| 952 | + public override Endpoint Build() |
| 953 | + { |
| 954 | + throw new NotImplementedException(); |
| 955 | + } |
| 956 | + } |
926 | 957 | } |
0 commit comments