|
|
@ -17,10 +17,33 @@ Function Assert-Equals($actual, $expected) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Function Get-PagefilePath() {
|
|
|
|
|
|
|
|
$pagefile = $null
|
|
|
|
|
|
|
|
$cs = Get-CimInstance -ClassName Win32_ComputerSystem
|
|
|
|
|
|
|
|
if ($cs.AutomaticManagedPagefile) {
|
|
|
|
|
|
|
|
$pagefile = "$($env:SystemRoot.Substring(0, 1)):\pagefile.sys"
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$pf = Get-CimInstance -ClassName Win32_PageFileSetting
|
|
|
|
|
|
|
|
if ($null -ne $pf) {
|
|
|
|
|
|
|
|
$pagefile = $pf[0].Name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $pagefile
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pagefile = Get-PagefilePath
|
|
|
|
|
|
|
|
if ($pagefile) {
|
|
|
|
# Test-AnsiblePath Hidden system file
|
|
|
|
# Test-AnsiblePath Hidden system file
|
|
|
|
$actual = Test-AnsiblePath -Path C:\pagefile.sys
|
|
|
|
$actual = Test-AnsiblePath -Path $pagefile
|
|
|
|
Assert-Equals -actual $actual -expected $true
|
|
|
|
Assert-Equals -actual $actual -expected $true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get-AnsibleItem file
|
|
|
|
|
|
|
|
$actual = Get-AnsibleItem -Path $pagefile
|
|
|
|
|
|
|
|
Assert-Equals -actual $actual.FullName -expected $pagefile
|
|
|
|
|
|
|
|
Assert-Equals -actual $actual.Attributes.HasFlag([System.IO.FileAttributes]::Directory) -expected $false
|
|
|
|
|
|
|
|
Assert-Equals -actual $actual.Exists -expected $true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Test-AnsiblePath File that doesn't exist
|
|
|
|
# Test-AnsiblePath File that doesn't exist
|
|
|
|
$actual = Test-AnsiblePath -Path C:\fakefile
|
|
|
|
$actual = Test-AnsiblePath -Path C:\fakefile
|
|
|
|
Assert-Equals -actual $actual -expected $false
|
|
|
|
Assert-Equals -actual $actual -expected $false
|
|
|
@ -46,13 +69,6 @@ Assert-Equals -actual $failed -expected $true
|
|
|
|
$actual = Get-AnsibleItem -Path C:\fakefile -ErrorAction SilentlyContinue
|
|
|
|
$actual = Get-AnsibleItem -Path C:\fakefile -ErrorAction SilentlyContinue
|
|
|
|
Assert-Equals -actual $actual -expected $null
|
|
|
|
Assert-Equals -actual $actual -expected $null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get-AnsibleItem file
|
|
|
|
|
|
|
|
$actual = Get-AnsibleItem -Path C:\pagefile.sys
|
|
|
|
|
|
|
|
Assert-Equals -actual $actual.FullName -expected C:\pagefile.sys
|
|
|
|
|
|
|
|
Assert-Equals -actual $actual.Attributes.HasFlag([System.IO.FileAttributes]::Directory) -expected $false
|
|
|
|
|
|
|
|
Assert-Equals -actual $actual.Exists -expected $true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get-AnsibleItem directory
|
|
|
|
# Get-AnsibleItem directory
|
|
|
|
$actual = Get-AnsibleItem -Path C:\Windows
|
|
|
|
$actual = Get-AnsibleItem -Path C:\Windows
|
|
|
|
Assert-Equals -actual $actual.FullName -expected C:\Windows
|
|
|
|
Assert-Equals -actual $actual.FullName -expected C:\Windows
|
|
|
|