2012-04-04 76 views
0

我有下一個路由。通過TestHelper測試路由限制

routes.MapRoute("Companies", "Companies/{companyId}", 
    new { controller = "Company", action = "Details" }, 
    new { companyId = @"\d+" }); 

這裏是測試它的測試。

"~/Companies/7".ShouldMapTo<CompanyController>(action => action.Details(7)); 

現在我想測試約束。所以url「〜/ Companies/df」不應該映射到控制器。

有誰知道如何測試它?

+0

的可能重複的[使用MvcContrib TestHelper斷言一個呼入路由不應被映射(http://stackoverflow.com/questions/9007331/using-mvccontrib-testhelper-to-assert-that-an -inbound路線 - 應該 - 不被映射) – 2012-04-04 18:13:05

回答

0
"~/Companies/df".ShouldBeIgnored();