2013-10-10 31 views
2

我以下A按mvc4收據書,我用下面的例子Assert.IsInstanceOfType不能從對象轉換爲System.Type的

// 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的,對象)的最佳重載的方法匹配具有一些無效參數

回答

2

你需要換你的論點

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

最好的重載方法匹配 Nunit.Framework.Assert.IsInstanceOfType(System.Type的,對象)有一些 無效的參數

它說,第一個變元t是System.Type,object