How do unit testing for IgnoreRoute in ASP.NET MVC

后端 未结 2 511
终归单人心
终归单人心 2021-02-14 00:22

In ASP.NET MVC, I can get information on unit testing for routes and custom routes, but I can not figure out how to do unit testing for IgnoreRoute.

routes.IgnoreRoute(\

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-14 00:34

    If you use the MvcContrib testhelper class (http://nuget.org/packages/MvcContrib.Mvc3.TestHelper-ci), you can simpifly it even further:

    [TestMethod]
    public void TestIgnoredRoute()
    {
        // Arrange
        RouteTable.Routes.Clear();
    
        // Act
        GlobalApplication.RegisterRoutes(RouteTable.Routes);
    
        // Assert
        "~/some.axd/path".ShouldBeIgnored();
    }
    

提交回复
热议问题