forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNullableBooleanDCR.Tests.ps1
More file actions
50 lines (43 loc) · 1.79 KB
/
Copy pathNullableBooleanDCR.Tests.ps1
File metadata and controls
50 lines (43 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Describe "Nullable Boolean DCR Tests" -Tags "CI" {
BeforeAll {
function ParserTestFunction
{
param([bool]$First) $PSBoundParameters
}
function parsertest-bool2
{
[CmdletBinding()]
param (
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)] [bool]$First = $false
)
Process {
return $PSBoundParameters
}
}
$testCases = @(
@{ Arg = $true; Expected = $true }
@{ Arg = 1; Expected = $true }
@{ Arg = 1.28; Expected = $true }
@{ Arg = (-2.32); Expected = $true }
@{ Arg = $false; Expected = $false }
@{ Arg = 0; Expected = $false }
@{ Arg = 0.00; Expected = $false }
@{ Arg = (1 - 1); Expected = $false }
)
}
It 'Test a boolean parameter accepts positional values, input:<Arg>, expect:<Expected>' -TestCases $testCases {
param($Arg, $Expected)
(parsertestfunction $Arg).Values[0] | Should Be $Expected
(parsertest-bool2 $Arg).Values[0] | Should Be $Expected
}
It 'Test a boolean parameter accepts values specified with a colon, input:<Arg>, expect:<Expected>' -TestCases $testCases {
param($Arg, $Expected)
(parsertestfunction -First:$Arg).Values[0] | Should Be $Expected
(parsertest-bool2 -First:$Arg).Values[0] | Should Be $Expected
}
It 'Test a boolean parameter accepts values specified with general format, input:<Arg>, expect:<Expected>' -TestCases $testCases {
param($Arg, $Expected)
(parsertestfunction -First $Arg).Values[0] | Should Be $Expected
(parsertest-bool2 -First $Arg).Values[0] | Should Be $Expected
}
}