开发者

Machine.Specifications.MVC ShouldBeAView() always fails even on valid ViewResults

开发者 https://www.devze.com 2022-12-21 09:55 出处:网络
Has anyone run into this while using Machine.Specifications.Mvc? I setup a spec to test the results of a controller action. In this case:

Has anyone run into this while using Machine.Specifications.Mvc?

I setup a spec to test the results of a controller action. In this case:

[Subject("User views the dashboard")]
public class When_a_user_views_the_vendors_page
     : ManagementContext
{
    static ActionResult result;

    Because of = () => result = manageController.Vendors();

    It should_contain_a_list_of_vendors = () => {

        result.ShouldBeAView().And().ShouldHaveModelOfType<List<Core.Vendor>>();
    };
}

The error I get every time is:

Machine.Specifications.SpecificationException: Should be of type System.Web.Mvc.ViewResult but is of type System.Web.Mvc.ViewResult at Machine.Specifications.ShouldExtensionMethods.ShouldBeOfType(Object actual, Type expected) in d:\BuildAgent-01\work\340c36596c29db8\Source\Machine.Specifications\ExtensionMethods.cs:line 206

Has anyone seen thi开发者_如何学编程s? Is there an easy way to resolve it? It seems to be happening in the Machine.Specifications library. I even ran it in a debug mode to check the values and they are indeed both ViewResult objects and with the correct model data even.

Thanks in advance


Okay... Silly problem. (I knew it would be). I've recently begun experimenting with MVC2. Machine.Specifications.Mvc out of the box is wired to 1.0;

I re-referenced Machine.Specifications.Mvc to Mvc2, and it worked like a charm.

doh! :)

0

精彩评论

暂无评论...
验证码 换一张
取 消