使用 MvcContrib TestHelper 断言不应映射入站路由
在名为 ShouldNotMap 的 MvcContrib.TestHelper.RouteTestingExtensions
类上查找方法。有 ShouldBeIgnored,但我不想测试 IgnoreRoute
调用。我想测试特定的传入路由不应映射到任何资源。
有没有办法使用 MvcContrib TestHelper 来做到这一点?
更新
刚刚尝试过,它似乎有效。这是正确的方法吗?
"~/do/not/map/this".Route().ShouldBeNull();
Looked for a method on the MvcContrib.TestHelper.RouteTestingExtensions
class named ShouldNotMap. There is ShouldBeIgnored, but I don't want to test an IgnoreRoute
invocation. I want to test that a specific incoming route should not be mapped to any resource.
Is there a way to do this using MvcContrib TestHelper?
Update
Just tried this, and it seems to work. Is this the correct way?
"~/do/not/map/this".Route().ShouldBeNull();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在寻找以下内容:
在幕后,这断言路由是由 StopRoutingHandler 处理的。
I think you are looking for the following:
Behind the scenes this asserts that the route is processed by StopRoutingHandler.
我一直在寻找同样的东西。我最终添加了以下扩展方法来实现
ShouldBeNull
和更短的ShouldNotMap
:在
RouteTestingExtensions.cs
中:在
GeneralTestExtensions.cs 中:
I was looking for the same thing. I ended up adding the following extension methods to implement
ShouldBeNull
and the even shorterShouldNotMap
:In
RouteTestingExtensions.cs
:In
GeneralTestExtensions.cs
: