Skip to content

Commit a6a69a8

Browse files
committed
Added test to cover multiple handler parameters bound to single route parameters.
1 parent 2b6318a commit a6a69a8

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/Framework/AspNetCoreAnalyzers/test/RouteHandlers/DisallowNonParsableComplexTypesOnParametersTest.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,31 @@ public class Customer
226226
await VerifyCS.VerifyAnalyzerAsync(source, expectedDiagnostic);
227227
}
228228

229+
[Fact]
230+
public async Task Route_Parameter_withTwoReceivingHandlerParameters_Works()
231+
{
232+
// Arrange
233+
var source = $$"""
234+
using System;
235+
using Microsoft.AspNetCore.Builder;
236+
using Microsoft.AspNetCore.Mvc;
237+
var webApp = WebApplication.Create();
238+
webApp.MapGet("/customers/{cust}", ([FromRoute(Name = "cust")]Customer customer, [FromRoute(Name = "cust")]string customerKey) => {});
239+
240+
public class Customer
241+
{
242+
public static bool TryParse(string s, IFormatProvider provider, out Customer result)
243+
{
244+
result = new Customer();
245+
return true;
246+
}
247+
}
248+
""";
249+
250+
// Act
251+
await VerifyCS.VerifyAnalyzerAsync(source);
252+
}
253+
229254
[Fact]
230255
public async Task Route_Parameter_withNameChanged_viaFromRoute_whenParsable_Works()
231256
{
@@ -549,7 +574,7 @@ public class Customer
549574
}
550575

551576
[Fact]
552-
public async Task Handler_Parameter_withWellknownTypes_Works()
577+
public async Task Handler_Parameter_withWellKnownTypes_Works()
553578
{
554579
// Arrange
555580
var source = $$"""

0 commit comments

Comments
 (0)