File tree Expand file tree Collapse file tree
AspNetCoreAnalyzers.Tests
ASP002MissingParameterTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,27 @@ public IActionResult GetId(string value)
3838 AnalyzerAssert . Valid ( Analyzer , code ) ;
3939 }
4040
41+ [ TestCase ( "\" api/orders/\" + \" {wrong}\" " ) ]
42+ public void IgnoreWhen ( string template )
43+ {
44+ var code = @"
45+ namespace ValidCode
46+ {
47+ using Microsoft.AspNetCore.Mvc;
48+
49+ [ApiController]
50+ public class OrdersController : Controller
51+ {
52+ [HttpGet(""api/orders/{value}"")]
53+ public IActionResult GetId(string value)
54+ {
55+ return this.Ok(value);
56+ }
57+ }
58+ }" . AssertReplace ( "\" api/orders/{value}\" " , template ) ;
59+ AnalyzerAssert . Valid ( Analyzer , code ) ;
60+ }
61+
4162 [ Test ]
4263 public void ImplicitFromRoute ( )
4364 {
Original file line number Diff line number Diff line change @@ -34,6 +34,27 @@ public IActionResult GetValue(string text)
3434 AnalyzerAssert . Valid ( Analyzer , code ) ;
3535 }
3636
37+ [ TestCase ( "\" api/orders/\" + \" {wrong}\" " ) ]
38+ public void IgnoreWhen ( string template )
39+ {
40+ var code = @"
41+ namespace ValidCode
42+ {
43+ using Microsoft.AspNetCore.Mvc;
44+
45+ [ApiController]
46+ public class OrdersController : Controller
47+ {
48+ [HttpGet(""api/orders/{value}"")]
49+ public IActionResult GetId(string value)
50+ {
51+ return this.Ok(value);
52+ }
53+ }
54+ }" . AssertReplace ( "\" api/orders/{value}\" " , template ) ;
55+ AnalyzerAssert . Valid ( Analyzer , code ) ;
56+ }
57+
3758 [ Test ]
3859 public void ImplicitFromRoute ( )
3960 {
Original file line number Diff line number Diff line change @@ -52,6 +52,27 @@ public IActionResult GetId(byte id)
5252 AnalyzerAssert . Valid ( Analyzer , code ) ;
5353 }
5454
55+ [ TestCase ( "\" api/orders/\" + \" {value:int}\" " ) ]
56+ public void IgnoreWhen ( string template )
57+ {
58+ var code = @"
59+ namespace ValidCode
60+ {
61+ using Microsoft.AspNetCore.Mvc;
62+
63+ [ApiController]
64+ public class OrdersController : Controller
65+ {
66+ [HttpGet(""api/orders/{value}"")]
67+ public IActionResult GetId(string value)
68+ {
69+ return this.Ok(value);
70+ }
71+ }
72+ }" . AssertReplace ( "\" api/orders/{value}\" " , template ) ;
73+ AnalyzerAssert . Valid ( Analyzer , code ) ;
74+ }
75+
5576 [ Test ]
5677 public void ImplicitType ( )
5778 {
You can’t perform that action at this time.
0 commit comments