[英]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.