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

标签 asp.net-mvc mspec

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

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

[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: 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

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

提前致谢

最佳答案

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

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

哦! :)

关于asp.net-mvc - 即使在有效的 ViewResults 上,Machine.Specifications.MVC ShouldBeAView() 也总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2314773/

相关文章:

testing - 如何使用 Rhino Mocks 和 MSpec 测试抽象类的虚拟属性?

asp.net-mvc - ASP.NET MVC Razor语法错误

c# - 每次使用 "Not Allowed"使用 ASP Identity 登录失败(即使 'email' 和 'username' 具有相同的值))

c# - 在 Entity Framework 中不使用 Dispose 或 using()

jQuery 选择动态生成的选项卡

visual-studio-2008 - 从单元测试生成经理报告 (Visual Studio)

asp.net-mvc - 使用带有 MVC5 属性路由的自定义路由处理程序

c# - 测试大型状态机有哪些策略?

.net - .net 中流行哪些 BDD 框架?

c# - MSpec:如何使静态变量线程安全?