This repository was archived by the owner on Aug 30, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
samples/PowerUtils.AspNetCore.ErrorHandler.Samples/Controllers
src/PowerUtils.AspNetCore.ErrorHandler
tests/PowerUtils.AspNetCore.ErrorHandler.Tests/ControllersTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ namespace PowerUtils.AspNetCore.ErrorHandler.Samples.Controllers;
88[ Route ( "errors-4xx" ) ]
99public class Errors4xxController : ControllerBase
1010{
11+ [ HttpGet ]
12+ public IActionResult Get ( )
13+ => Ok ( "Success..." ) ;
14+
1115 [ HttpGet ( "400" ) ]
1216 public IActionResult Error400 ( )
1317 => BadRequest ( ) ;
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ private static string _formatPropertyToCamelCase(string propertyName)
136136 private static string _formatPropertyToSnakeCase ( string propertyName )
137137 {
138138 var propertyParts = propertyName . Split ( '.' ) ;
139-
139+
140140 for ( var count = 0 ; count < propertyParts . Length ; count ++ )
141141 {
142142 propertyParts [ count ] = propertyParts [ count ] . ToSnakeCase ( ) ;
Original file line number Diff line number Diff line change @@ -118,4 +118,24 @@ public async Task Error_422()
118118
119119 content . ValidateContent ( HttpStatusCode . UnprocessableEntity ) ;
120120 }
121+
122+ [ Fact ( DisplayName = "Using the verb POST to call an endpoint with verb GET - Should return a problem details response with error code 405" ) ]
123+ public async Task GetEndpoint_UsePOSTVerbs_405 ( )
124+ {
125+ // Arrange
126+ var requestUri = "/errors-4xx" ;
127+
128+
129+ // Act
130+ ( var response , var content ) = await _testsFixture . Client . SendPostAsync ( requestUri ) ;
131+
132+
133+ // Assert
134+ response . ValidateResponse ( HttpStatusCode . MethodNotAllowed ) ;
135+
136+ content . ValidateContent (
137+ HttpStatusCode . MethodNotAllowed ,
138+ "POST: " + requestUri
139+ ) ;
140+ }
121141}
You can’t perform that action at this time.
0 commit comments