|
|
|
@ -17,9 +17,32 @@ Function Assert-Equals($actual, $expected) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Test-AnsiblePath Hidden system file
|
|
|
|
|
$actual = Test-AnsiblePath -Path C:\pagefile.sys
|
|
|
|
|
Assert-Equals -actual $actual -expected $true
|
|
|
|
|
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
|
|
|
|
|
$actual = Test-AnsiblePath -Path $pagefile
|
|
|
|
|
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
|
|
|
|
|
$actual = Test-AnsiblePath -Path C:\fakefile
|
|
|
|
@ -46,13 +69,6 @@ Assert-Equals -actual $failed -expected $true
|
|
|
|
|
$actual = Get-AnsibleItem -Path C:\fakefile -ErrorAction SilentlyContinue
|
|
|
|
|
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
|
|
|
|
|
$actual = Get-AnsibleItem -Path C:\Windows
|
|
|
|
|
Assert-Equals -actual $actual.FullName -expected C:\Windows
|
|
|
|
|