Correct case of $true special variable

This commit is contained in:
xtqqczze 2020-01-13 19:25:09 +00:00
parent 6014f4bac3
commit 47a3b4e293
13 changed files with 44 additions and 44 deletions

View file

@ -185,7 +185,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
It "-File should be able to pass bool string values as string to parameters: <BoolString>" -TestCases @(
# validates case is preserved
@{BoolString = '$truE'},
@{BoolString = '$true'},
@{BoolString = '$falSe'},
@{BoolString = 'trUe'},
@{BoolString = 'faLse'}
@ -198,7 +198,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
It "-File should be able to pass bool string values as string to positional parameters: <BoolString>" -TestCases @(
# validates case is preserved
@{BoolString = '$tRue'},
@{BoolString = '$true'},
@{BoolString = '$falSe'},
@{BoolString = 'tRUe'},
@{BoolString = 'fALse'}
@ -210,7 +210,7 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
}
It "-File should be able to pass bool string values as bool to switches: <BoolString>" -TestCases @(
@{BoolString = '$tRue'; BoolValue = 'True'},
@{BoolString = '$true'; BoolValue = 'True'},
@{BoolString = '$faLse'; BoolValue = 'False'},
@{BoolString = 'tRue'; BoolValue = 'True'},
@{BoolString = 'fAlse'; BoolValue = 'False'}

View file

@ -741,28 +741,28 @@ foo``u{2195}abc
@{ Script = 'if (0 -or 1) { $true } else { $false }'; Expected = $true }
@{ Script = 'if (0 -or 0) { $true } else { $false }'; Expected = $false }
#-eq
@{ Script = 'if ($False -eq $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -eq $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -eq $true -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $true -eq $False) { $true } else { $false }'; Expected = $false }
#-ieq
@{ Script = 'if ($False -ieq $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ieq $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -ieq $true -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $true -ieq $False) { $true } else { $false }'; Expected = $false }
#-le
@{ Script = 'if ($False -le $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -le $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -le $true -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $true -le $False) { $true } else { $false }'; Expected = $false }
#-ile
@{ Script = 'if ($False -ile $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ile $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -ile $true -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $true -ile $False) { $true } else { $false }'; Expected = $false }
#-ge
@{ Script = 'if ($False -ge $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ge $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -ge $true -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $true -ge $False) { $true } else { $false }'; Expected = $false }
#-ige
@{ Script = 'if ($False -ige $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -ige $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -ige $true -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $true -ige $False) { $true } else { $false }'; Expected = $false }
#-like
@{ Script = 'if ($False -like $True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $True -like $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -like $true -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if ($False -and $true -like $False) { $true } else { $false }'; Expected = $false }
#!
@{ Script = 'if (!$True -and $False) { $true } else { $false }'; Expected = $false }
@{ Script = 'if (!$true -and $False) { $true } else { $false }'; Expected = $false }
)
It "<Script> should return <Expected>" -TestCases $testData {
param ( $Script, $Expected )

View file

@ -11,7 +11,7 @@ Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
$global:PSDefaultParameterValues = $defaultParamValues
}
It "should be able to Clear-EventLog" -Pending:($True) {
It "should be able to Clear-EventLog" -Pending:($true) {
Remove-EventLog -LogName TestLog -ErrorAction Ignore
{ New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop } | Should -Not -Throw
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Not -Throw
@ -24,11 +24,11 @@ Describe "Clear-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
{ Remove-EventLog -LogName TestLog -ErrorAction Stop } | Should -Not -Throw
}
It "should throw 'System.InvalidOperationException' when asked to clear a log that does not exist" -Pending:($True) {
It "should throw 'System.InvalidOperationException' when asked to clear a log that does not exist" -Pending:($true) {
{ Clear-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ExceptionType "System.InvalidOperationException"
}
It "should throw 'Microsoft.PowerShell.Commands.ClearEventLogCommand' ErrorId when asked to clear a log that does not exist" -Pending:($True) {
It "should throw 'Microsoft.PowerShell.Commands.ClearEventLogCommand' ErrorId when asked to clear a log that does not exist" -Pending:($true) {
{ Clear-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.ClearEventLogCommand"
}
}

View file

@ -11,15 +11,15 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
$global:PSDefaultParameterValues = $defaultParamValues
}
#CmdLets are not yet implemented, so these cases are -Pending:($True) for now...
It "should return an array of eventlogs objects when called with -AsString parameter" -Pending:($True) {
#CmdLets are not yet implemented, so these cases are -Pending:($true) for now...
It "should return an array of eventlogs objects when called with -AsString parameter" -Pending:($true) {
{ $result=Get-EventLog -AsString -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
,$result | Should -BeOfType "System.Array"
$result | Should -BeExactly "Application"
$result.Count | Should -BeGreaterThan 3
}
It "should return a list of eventlog objects when called with -List parameter" -Pending:($True) {
It "should return a list of eventlog objects when called with -List parameter" -Pending:($true) {
{ $result=Get-EventLog -List -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
,$result | Should -BeOfType "System.Array"
@ -27,22 +27,22 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
$logs | Should -BeExactly "System"
$logs.Count | Should -BeGreaterThan 3
}
It "should be able to Get-EventLog -LogName Application -Newest 100" -Pending:($True) {
It "should be able to Get-EventLog -LogName Application -Newest 100" -Pending:($true) {
{ $result=get-eventlog -LogName Application -Newest 100 -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
$result.Length | Should -BeLessThan 100
$result[0] | Should -BeOfType "EventLogEntry"
}
It "should throw 'AmbiguousParameterSetException' when called with both -LogName and -List parameters" -Pending:($True) {
It "should throw 'AmbiguousParameterSetException' when called with both -LogName and -List parameters" -Pending:($true) {
{ Get-EventLog -LogName System -List -ErrorAction Stop } | Should -Throw -ErrorId "AmbiguousParameterSet,Microsoft.PowerShell.Commands.GetEventLogCommand"
}
It "should be able to Get-EventLog -LogName * with multiple matches" -Pending:($True) {
It "should be able to Get-EventLog -LogName * with multiple matches" -Pending:($true) {
{ $result=get-eventlog -LogName * -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
$result | Should -BeExactly "Security"
$result.Count | Should -BeGreaterThan 3
}
It "should throw 'InvalidOperationException' when asked to get a log that does not exist" -Pending:($True) {
It "should throw 'InvalidOperationException' when asked to get a log that does not exist" -Pending:($true) {
{ Get-EventLog -LogName MissingTestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"
}
}

View file

@ -18,34 +18,34 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
}
}
It "should be able to create a New-EventLog with a -Source parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -Source parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
}
It "should be able to create a New-EventLog with a -ComputerName parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -ComputerName parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ComputerName $env:COMPUTERNAME -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
$result.EventID | Should -Be 1
}
It "should be able to create a New-EventLog with a -CategoryResourceFile parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -CategoryResourceFile parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -CategoryResourceFile "CategoryMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 2 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
$result.EventID | Should -Be 2
}
It "should be able to create a New-EventLog with a -MessageResourceFile parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -MessageResourceFile parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -MessageResourceFile "ResourceMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 3 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog
$result.Count | Should -Be 1
$result.EventID | Should -Be 3
}
It "should be able to create a New-EventLog with a -ParameterResourceFile parameter" -Skip:($True) {
It "should be able to create a New-EventLog with a -ParameterResourceFile parameter" -Skip:($true) {
{New-EventLog -LogName TestLog -Source TestSource -ParameterResourceFile "ParameterMessageFile" -ErrorAction Stop} | Should -Not -Throw
{Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 4 -ErrorAction Stop} | Should -Not -Throw
$result=Get-EventLog -LogName TestLog

View file

@ -20,13 +20,13 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
}
}
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
It "should be able to Remove-EventLog -LogName <string> -ComputerName <string>" -Pending:($True) {
It "should be able to Remove-EventLog -LogName <string> -ComputerName <string>" -Pending:($true) {
{ Remove-EventLog -LogName TestLog -ComputerName $env:COMPUTERNAME -ErrorAction Stop } | Should -Not -Throw
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.WriteEventLogCommand"
{ Get-EventLog -LogName TestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"
}
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
It "should be able to Remove-EventLog -Source <string> -ComputerName <string>" -Pending:($True) {
It "should be able to Remove-EventLog -Source <string> -ComputerName <string>" -Pending:($true) {
{Remove-EventLog -Source TestSource -ComputerName $env:COMPUTERNAME -ErrorAction Stop} | Should -Not -Throw
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.WriteEventLogCommand"
{ Get-EventLog -LogName TestLog -ErrorAction Stop; } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"

View file

@ -75,7 +75,7 @@ Describe "Unblock-File" -Tags "CI" {
It "Write an error if a file is read only" {
$TestFile = Join-Path $TestDrive "testfileunlock.ps1"
Block-File -Path $TestFile
Set-ItemProperty -Path $TestFile -Name IsReadOnly -Value $True
Set-ItemProperty -Path $TestFile -Name IsReadOnly -Value $true
$TestFileCreated = Get-ChildItem $TestFile
$TestFileCreated.IsReadOnly | Should -BeTrue

View file

@ -220,7 +220,7 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
$newLine = [System.Environment]::NewLine
$expectedContent = "$message$($newLine)Confirm$($newLine)Continue with this operation?"
$script = {
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $True)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $true)
Start-Transcript -Path $transcriptFilePath
Write-Information -Message $message -InformationAction Inquire
Stop-Transcript
@ -280,7 +280,7 @@ Describe "Start-Transcript, Stop-Transcript tests" -tags "CI" {
$newLine = [System.Environment]::NewLine
$expectedContent = "$message$($newLine)Confirm$($newLine)Continue with this operation?"
$script = {
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $True)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('ForcePromptForChoiceDefaultOption', $true)
Start-Transcript -Path $transcriptFilePath
Write-Host -Message $message -InformationAction Inquire
Stop-Transcript

View file

@ -27,7 +27,7 @@ Describe "Test suite for validating automounted PowerShell drives" -Tags @('Feat
$tmpVhdPath = Join-Path $TestDrive 'TestVHD.vhd'
New-VHD -path $tmpVhdPath -SizeBytes 5mb -Dynamic -ErrorAction Stop
Remove-Item $tmpVhdPath
$VHDToolsNotFound = (Get-Module Hyper-V).PrivateData.ImplicitRemoting -eq $True
$VHDToolsNotFound = (Get-Module Hyper-V).PrivateData.ImplicitRemoting -eq $true
Remove-Module Hyper-V
}
catch

View file

@ -8,7 +8,7 @@ Describe 'Group policy settings tests' -Tag CI,RequireAdminOnWindows {
$PSDefaultParameterValues["it:skip"] = $true
}
else {
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('BypassGroupPolicyCaching', $True)
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('BypassGroupPolicyCaching', $true)
}
}
AfterAll {

View file

@ -33,7 +33,7 @@ Describe "BooleanParameterDCR Tests" -tags "CI" {
$tests = @(
@{ inputTest = $(1 -eq 1); expected = $true },
@{ inputTest = $true; expected = $true },
@{ inputTest = $TRUE; expected = $true }
@{ inputTest = $true; expected = $true }
)
It "Test that $true is accepted as a true value for Switch parameters, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
param ( $inputTest, $expected )

View file

@ -30,7 +30,7 @@ try {
$result.SkipCACheck = $true
$result.SkipCNCheck = $true
$result.SkipRevocationCheck = $true
$result.UseUtf16 = $True
$result.UseUtf16 = $true
$result.UseEncryption = $false
$result.ProxyAuthentication = "Negotiate"
$result.SPNPort = 10

View file

@ -8,7 +8,7 @@ function Get-ParseResults
{
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$True,Mandatory=$True)]
[Parameter(ValueFromPipeline=$true,Mandatory=$true)]
[string]$src,
[switch]$Ast
)
@ -25,7 +25,7 @@ function Get-RuntimeError
{
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$True,Mandatory=$True)][string]$src
[Parameter(ValueFromPipeline=$true,Mandatory=$true)][string]$src
)
$errors = $null