即使在有效的 ViewResults 上,Machine.Specifications.MVC ShouldBeAView() 也总是失败

发布于 2024-08-23 06:48:17 字数 955 浏览 8 评论 0原文

有人在使用 Machine.Specifications.Mvc 时遇到过这个问题吗?

我设置了一个规范来测试控制器操作的结果。在这种情况下:

[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>>();
    };
}

我每次得到的错误是:

Machine.Specifications.SpecificationException:应该是 System.Web.Mvc.ViewResult 类型,但实际上是 System.Web.Mvc.ViewResult 类型 在 d:\BuildAgent-01\work\340c36596c29db8\Source\Machine.Specifications\ExtensionMethods.cs 中的 Machine.Specifications.ShouldExtensionMethods.ShouldBeOfType(实际对象,预期类型):第 206 行

有人见过这个吗?有没有简单的方法可以解决呢?它似乎发生在 Machine.Specifications 库中。我什至在调试模式下运行它来检查这些值,它们确实都是 ViewResult 对象,甚至具有正确的模型数据。

提前致谢

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 this? 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2024-08-30 06:48:17

好吧...愚蠢的问题。 (我就知道会是这样)。我最近开始尝试 MVC2。 Machine.Specifications.Mvc 开箱即用,连接到 1.0;

我将 Machine.Specifications.Mvc 重新引用到 Mvc2,它的效果非常好。

哦! :)

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! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文