Why mvccontrib AssertViewRendered (). ForView ("Edit") crashing because view name is full cshtml outline?

I have the following unit test:

    [TestMethod]
    public void Add_Returns_Edit_View()
    {
        // Act
        ActionResult result = _controller.Add();

        // Verify
        result.AssertViewRendered().ForView("Edit");
    }

This must be passed, since the Add action returns an Edit view. However, this statement fails with the following exception:

MvcContrib.TestHelper.ActionResultAssertionException: Expected view name 'Edit', actual was '~/Views/JobSearch/Edit.cshtml'

Why is the view name returned as the fully qualified path name? Could this be due to my use of T4MVC, and if so, how can I convey this?


Change View Add is as follows:
    public virtual ActionResult Add()
    {
        return View(MVC.JobSearch.Views.Edit, new JobSearch());
    }
+5
source share
2 answers

You can test the value of T4MVC as follows:

result.AssertViewRendered().ForView(MVC.JobSearch.Views.Edit);

, ... :)

+3

. , T4MVC, , . , MVC.JobSearch.Views.Edit "~/Views/JobSearch/Edit.cshtml", .ForView() , View().

.

+1

All Articles