/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/powershell/engine/ParameterBinding/NullableBooleanDCR.Tests.ps1
52 строки
2 KB
Steve Lee
Update copyright notice to latest guidance (#12190)
24 мар 2020, 21:08
Не верифицирован
24 мар 2020, 21:08
b7cb335
Код
Авторство
О чём код?
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. 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 } }