I am using MvcContrib-TestHelper to test the routing on my app. I have an action which is restricted to HTTP POST only:
public TestController
{
[HttpPost]
public ActionResult Example()
{
return View();
}
}
And here is an example of a test that should fail:
[TestFixture]
public class RoutingTests
{
[TestFixtureSetUp]
public void TestFixtureSetUp()
{
RouteTable.Routes.Clear();
Application.RegisterRoutes(RouteTable.Routes);
}
[Test]
public void TestWithGet()
{
var route = "~/Test/Example".WithMethod(HttpVerbs.Get);
route.ShouldMapTo(r => r.Example());
}
}
However, the test passes! I've seen one other unanswered question (sorry, wrong link) where this was also raised, and it seems like the functionality is broken. What's a better way to test that this route is accessible via POST only?
use this code:
attributes - this is list accept verbs