微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – MvcContrib TestHelper在使用AssertViewRendered时发出奇怪的错误

我正在尝试使用MvcContrib Test Helper来测试MVC3中的控制器方法.

控制器:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

考试:

[TestMethod]
public void Index()
{
    // Arrange
    HomeController controller = new HomeController();

    // Act
    ViewResult result = controller.Index() as ViewResult;

    // Assert
    result.AssertVieWrendered().ForView("Index");
}

错误

Test method Tests.Web.Controllers.HomeControllerTests.Index threw exception:
MvcContrib.TestHelper.ActionResultAssertionException:
Expected result to be of type ViewResult. It is actually of type ViewResult.

有任何想法吗?

解决方法

我的猜测是你正在使用MVCC的MVCC2,它使用MVC2 ViewResult.然而,你正在返回一个MVC3 ViewResult.

您是否尝试过针对MVC3编译MVCContrib?

原文地址:https://www.jb51.cc/csharp/100156.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐