Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Assert.IsInstanceOfType无法从对象转换为System.Type_C#_.net_Nunit - Fatal编程技术网

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

C# Assert.IsInstanceOfType无法从对象转换为System.Type,c#,.net,nunit,C#,.net,Nunit,我正在阅读一本关于mvc4收据的书,我正在努力学习下面的例子 // act ViewResult result = controller.Index() as ViewResult; // assert Assert.IsInstanceOfType(result.Model,typeof(List<Architect>)) //act ViewResult=controller.Index()作为ViewResult; //断言 Assert.IsInstanceOfType(r

我正在阅读一本关于mvc4收据的书,我正在努力学习下面的例子

// act
ViewResult result = controller.Index() as ViewResult;
// assert
Assert.IsInstanceOfType(result.Model,typeof(List<Architect>))
//act
ViewResult=controller.Index()作为ViewResult;
//断言
Assert.IsInstanceOfType(result.Model,typeof(列表))
这条线

Assert.IsInstanceOfType(result.Model,typeof(List<Architect>))
Assert.IsInstanceOfType(结果、模型、类型(列表))
抛出两个错误

  • Argument1:无法从对象转换为系统。类型
  • 与Nunit.Framework.Assert.IsInstanceOfType(System.Type,object)匹配的最佳重载方法具有一些无效参数

  • 你需要交换你的论点

    Assert.IsInstanceOfType(typeof(List<Architect>),result.Model);
    
    Assert.IsInstanceOfType(typeof(List),result.Model);
    
    匹配的最佳重载方法 Nunit.Framework.Assert.IsInstanceOfType(System.Type,object)有一些 无效参数

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