我正在使用Pester对我正在创建的模块进行一些单元测试,而且我的一个函数应该返回一个运行空间对象,我遇到了一些麻烦。当我创建一个runspace对象并执行.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()
的结果进行比较,但我真的宁愿使用Should BeOfType