[英]Issue with mvcContrib fluent route testing in asp.net mvc
我在使用MVCContrib Fluent路由測試來測試路由時遇到問題。 測試失敗,但應用程序識別出路由。
讓我解釋....
我的寄存器中有以下路線(按順序顯示)
routes.MapRoute(
"PurchaseUnitsPaged",
"PurchaseUnits/Page{page}",
new { controller = "PurchaseUnits", action = "Index", page = 1 },
new { page = @"\d+" }
);
routes.MapRoute(
"PurchaseUnit",
"PurchaseUnits/{unitname}",
new { controller = "PurchaseUnits", action = "Show" }
);
路由管道正確地將請求發送到索引以顯示路由1,並顯示請求以顯示路由2。
但是,當我使用MVCContrib流利的類測試路由時,路由1的測試失敗。
測試是:
"~/PurchaseUnits/Page{page}".ShouldMapTo<PurchaseUnitsController>(x=> x.Index(1));
測試失敗,因為期望值是Index而實際值是Show 。
關於為什么流利的類不能識別正確的路由,但mvc路由在實際應用程序中起作用的任何想法? 還是沒有任何有關如何調整測試或路線以使我能夠進行全面測試的建議?
您的測試應為:
"~/PurchaseUnits/Page1".ShouldMapTo<PurchaseUnitsController>(x=> x.Index(1));
網址是~/PurchaseUnits/Page1
而不是~/PurchaseUnits/Page{page}
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.