asp.net mvc 中的 mvcContrib 流畅路由测试问题
我在使用 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 的 Index 和路由 2 的 Show 但是,
当我使用 MVCContrib 流畅类测试路由时,路由 1 的测试失败。
测试是:
"~/PurchaseUnits/Page{page}".ShouldMapTo<PurchaseUnitsController>(x=> x.Index(1));
测试失败,因为期望是 Index 但实际是 Show。
关于为什么 flutter 类无法识别正确的路由而 mvc 路由在实际应用程序中起作用的任何想法吗?或者如果没有关于如何调整我的测试或路线以允许我进行全面测试的任何建议?
I have an issue with testing routes using the MVCContrib Fluent route testing. The test fails yet the application recognises the routes.
Let me explain....
I have the following routes in my register (shown in order)
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" }
);
The routing pipeline correctly sends requests to Index for route 1 and Show for route 2.
However when I test the routing using the MVCContrib fluent classes I get a test fail for route 1.
The test is:
"~/PurchaseUnits/Page{page}".ShouldMapTo<PurchaseUnitsController>(x=> x.Index(1));
The test fails because the expectation is Index but the actual is Show.
Any ideas as to why the fluent classes aren't identifying the correct routing yet the mvc routing works in the actual application? Or failing that any suggestions about how I can tweak my test or routes to allow me to fully test?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的测试应该是:
网址是
~/PurchaseUnits/Page1
而不是~/PurchaseUnits/Page{page}
。Your test should be:
The url is
~/PurchaseUnits/Page1
and not~/PurchaseUnits/Page{page}
.