单元测试 – MVCContrib测试路径与区域
发布时间:2020-12-16 06:43:04 所属栏目:asp.Net 来源:网络整理
导读:我正在使用带有区域的MVC 2.为了测试路由,我使用的是MvcContrib. 这是测试代码: [Test]public void Home(){ MvcApplication.RegisterRoutes(RouteTable.Routes); "~/".ShouldMapToHomeController(x = x.Login("Nps"));} 我不知道如何调用存储在Regions中的
我正在使用带有区域的MVC 2.为了测试路由,我使用的是MvcContrib.
这是测试代码: [Test] public void Home() { MvcApplication.RegisterRoutes(RouteTable.Routes); "~/".ShouldMapTo<HomeController>(x => x.Login("Nps")); } 我不知道如何调用存储在Regions中的路由定义. 谢谢 解决方法
这就是我这样做的方式,对我有用
[Test] public void VerifyRouteMapFor_Test_Area_TestController() { RouteTable.Routes.Clear(); var testAreaRegistration = new testAreaRegistration(); testAreaRegistration.RegisterArea(new AreaRegistrationContext(testAreaRegistration.AreaName,RouteTable.Routes)); "~/test/index".ShouldMapTo<testController>(x => x.Index()); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 验证摘要问题
- asp.net – 如何填写一个Label.Text – 通过jQuery的属性
- asp.net – 在Html.BeginForm之外提交按钮
- asp.net-mvc – 将ASP.NET MVC应用程序与Entity Framework分
- asp.net-mvc – 使用Windows身份验证和OWIN的ASP.NET MVC5
- asp.net-mvc – 控制器中的模拟服务器
- 如何在asp.Net中的脚本标签上使用runat =“server”
- 使用Asp.net的Amazon Book Search API
- asp-classic – 在经典ASP中检测字典对象
- asp.net – Webapi,Webhost和Owin之间的关系