1

我正在使用 Pester 对我正在创建的模块进行一些单元测试,并且我的一个应该返回运行空间对象的函数遇到了一些麻烦。当我创建一个运行空间对象并执行 a 时,.GetType()我看到名称列为 LocalRunspace,全名为 System.Management.Automation.Runspaces.LocalRunspace 但是当我运行$Runspace -is [LocalRunspace]$Runspace -is [System.Management.Automation.Runspaces.LocalRunspace]收到以下错误消息时

Unable to find type [System.Management.Automation.Runspaces.LocalRunspace]. Make sure that the assembly that contains this type is loaded.
At line:1 char:1
+ $ps.Runspace -is [System.Management.Automation.Runspaces.LocalRunspace]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (System.Manageme...s.LocalRunspace:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound

只是想弄清楚我应该引用什么类型以创建正确的验证检查。我知道我可以回退到与结果进行比较,.GetType()但我真的更愿意使用正常的 Pester 约定Should BeOfType

4

0 回答 0