Closed justmara closed 9 years ago
[RoutePrefix("test")] public class TestController : ApiController { [HttpGet, Route("{container}/{id}")] public async Task<IHttpActionResult> Get(string container, string id) { return Ok(); } [HttpPost, Route("{container}/{user}")] public async Task<IHttpActionResult> Add(string container, string user) { return Ok(); } }
So here is GET with id and POST with user second parameter names.
id
user
[TestMethod] public void TestGet() { var expectations = new { controller = "Test", action = "Get", container = "someContainer", id = "someId" }; RouteAssert.HasApiRoute(_host.Config, "/test/someContainer/someId", HttpMethod.Get, expectations); } [TestMethod] public void TestAddFail() { var expectations = new { controller = "Test", action = "Add", container = "someContainer", user = "someUser" }; RouteAssert.HasApiRoute(_host.Config, "/test/someContainer/someUser", HttpMethod.Post, expectations); }
The Add fails with Expected 'someUser', got missing value for 'user' at url '/test/someContainer/someUser'.
Expected 'someUser', got missing value for 'user' at url '/test/someContainer/someUser'.
So here is GET with
id
and POST withuser
second parameter names.The Add fails with
Expected 'someUser', got missing value for 'user' at url '/test/someContainer/someUser'.