Assert.IsInstanceOfType无法将对象转换为System.Type类型。

3
我正在按照Apress MVC4 Receipts书籍进行学习,但是我在跟随以下示例时遇到了困难。
// act
ViewResult result = controller.Index() as ViewResult;
// assert
Assert.IsInstanceOfType(result.Model,typeof(List<Architect>))

这一行

Assert.IsInstanceOfType(result.Model,typeof(List<Architect>))

抛出两个错误

  1. 参数1:无法将对象转换为 System.Type
  2. Nunit.Framework.Assert.IsInstanceOfType(System.Type, object) 的最佳重载匹配具有一些无效的参数
1个回答

3

你需要交换你的参数

Assert.IsInstanceOfType(typeof(List<Architect>),result.Model);

最佳重载方法匹配Nunit.Framework.Assert.IsInstanceOfType(System.Type, object)存在一些无效的参数。

它表示第一个参数是 System.Type ,第二个参数是 object


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接