c# - Assert.IsInstanceOfType 无法从对象转换为 System.Type

标签 c# .net nunit

我正在关注 apress mvc4 收据书,但我正在努力处理以下示例

// 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) 的最佳重载方法匹配有一些无效参数

最佳答案

你需要交换你的论点

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

The best overloaded method match for Nunit.Framework.Assert.IsInstanceOfType(System.Type, object) has some invalid arguments

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

关于c# - Assert.IsInstanceOfType 无法从对象转换为 System.Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19292005/

相关文章:

c# - 如何使用正则表达式在文本中添加回车符?

.net - Azure Active Directory API 始终显示禁止消息

c#-4.0 - 使用 [Range] 属性的类常量

selenium - Specflow-GenerateFeatureFileCodeBehindTask意外失败

c# - 通过 C 库在 C# 应用程序之间共享数据

c# - 以不区分大小写的方式查找子字符串 - C#

c# - object[] 是否装箱

c# - 使用.NET重命名计算机名称

c# - 我应该学习什么来提高我的技能?

c# - 值不能为空。参数名称 : request