【发布时间】:2016-11-12 20:27:39
【问题描述】:
Fluent Assertions 是一个用于任何类型断言的 .NET 库,但我无法让它与 PowerShell 一起使用。有可能吗?
我使用 Add-Type cmdlet 添加库的 DLL 并尝试了以下示例:
PS C:\Users\ymm> $test = 'test string'
PS C:\Users\ymm> $test.[FluentAssertions.AssertionExtensions]::Should().BeNull()
但出现以下错误:
Cannot find an overload for "Should" and the argument count: "0".
At line:1 char:1
+ $test.[FluentAssertions.AssertionExtensions]::Should().BeNull()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
【问题讨论】:
-
你看过 Pester (github.com/pester/Pester) 吗?它是为 Powershell 测试而编写的,因此没有原生 .NET 库的冗长。
-
Pester 不错,但不能与这个库相比。据我记得,它需要一定的文件结构和语法才能工作,即我不能只使用没有描述块等的断言本身。
标签: powershell fluent-assertions