gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:56:35 26 4
gpt4 key购买 nike

我正在关注 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com