@@ -11,15 +11,15 @@ public class CodeFix
1111 private static readonly ExpectedDiagnostic ExpectedDiagnostic = ExpectedDiagnostic . Create ( ASP004ParameterSyntax . Descriptor ) ;
1212 private static readonly CodeFixProvider Fix = new ParameterSyntaxFix ( ) ;
1313
14- [ TestCase ( "api/orders/↓id:long}" , "api/orders/{id:long}" ) ]
15- [ TestCase ( "api/orders/↓{id:long" , "api/orders/{id:long}" ) ]
16- [ TestCase ( "api/orders/{id:min(1}" , "api/orders/{id:min(1)}" ) ]
17- [ TestCase ( "api/orders/{id:max(1}" , "api/orders/{id:max(1)}" ) ]
18- [ TestCase ( "api/orders/{id:minlength(1}" , "api/orders/{id:minlength(1)}" ) ]
19- [ TestCase ( "api/orders/{id:maxlength(1}" , "api/orders/{id:maxlength(1)}" ) ]
20- [ TestCase ( "api/orders/{id:length(1}" , "api/orders/{id:length(1)}" ) ]
21- [ TestCase ( "api/orders/{id:length(1,2}" , "api/orders/{id:length(1,2)}" ) ]
22- [ TestCase ( "api/orders/{id:range(1,2}" , "api/orders/{id:range(1,2)}" ) ]
14+ [ TestCase ( "api/orders/↓id:long}" , "api/orders/{id:long}" ) ]
15+ [ TestCase ( "api/orders/↓{id:long" , "api/orders/{id:long}" ) ]
16+ [ TestCase ( "api/orders/{id:min(1}" , "api/orders/{id:min(1)}" ) ]
17+ [ TestCase ( "api/orders/{id:max(1}" , "api/orders/{id:max(1)}" ) ]
18+ [ TestCase ( "api/orders/{id:minlength(1}" , "api/orders/{id:minlength(1)}" ) ]
19+ [ TestCase ( "api/orders/{id:maxlength(1}" , "api/orders/{id:maxlength(1)}" ) ]
20+ [ TestCase ( "api/orders/{id:length(1}" , "api/orders/{id:length(1)}" ) ]
21+ [ TestCase ( "api/orders/{id:length(1,2}" , "api/orders/{id:length(1,2)}" ) ]
22+ [ TestCase ( "api/orders/{id:range(1,2}" , "api/orders/{id:range(1,2)}" ) ]
2323 [ TestCase ( "api/orders/{id:regex((a|b)-c}" , "api/orders/{id:regex((a|b)-c)}" ) ]
2424 public void WhenFixable ( string before , string after )
2525 {
@@ -56,5 +56,29 @@ public IActionResult GetId(long id)
5656}" . AssertReplace ( "api/orders/{id:long}" , after ) ;
5757 AnalyzerAssert . CodeFix ( Analyzer , Fix , ExpectedDiagnostic , code , fixedCode ) ;
5858 }
59+
60+ [ TestCase ( "api/orders/{id:↓wrong}" ) ]
61+ [ TestCase ( "api/orders/{id:min1)}" ) ]
62+ [ TestCase ( "api/orders/{id:max1)}" ) ]
63+ public void WhenNot ( string before )
64+ {
65+ var code = @"
66+ namespace ValidCode
67+ {
68+ using Microsoft.AspNetCore.Mvc;
69+
70+ [ApiController]
71+ public class OrdersController : Controller
72+ {
73+ [HttpGet(""api/orders/↓{id:wrong}"")]
74+ public IActionResult GetId(long id)
75+ {
76+ return this.Ok(id);
77+ }
78+ }
79+ }" . AssertReplace ( "api/orders/↓{id:wrong}" , before ) ;
80+
81+ AnalyzerAssert . Diagnostics ( Analyzer , ExpectedDiagnostic , code ) ;
82+ }
5983 }
6084}
0 commit comments