File size: 1,887 Bytes
8c763fb | 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 51 52 53 54 55 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "Get-ItemProperty" -Tags "CI" {
$currentDirectory = Split-Path $PSScriptRoot -Leaf
$parentDirectory = Split-Path (Join-Path -Path $PSScriptRoot -ChildPath "..") -Leaf
$tempDirectory = $TestDrive
$testprovider = (Get-Item $tempDirectory).PSDrive.Name
$testfile = Join-Path -Path $tempDirectory -ChildPath testfile1
New-Item $testfile -ItemType file -Force
It "Should be able to be called on in the current directory" {
$(Get-ItemProperty $PSScriptRoot).Name | Should -BeExactly $currentDirectory
}
It "Should be able to be called on a parent directory" {
(Get-ItemProperty $PSScriptRoot/..).Name | Should -BeExactly $parentDirectory
}
It "Should be able to be called on a directory using the path switch" {
{ Get-ItemProperty -Path $tempDirectory } | Should -Not -Throw
}
It "Should be able to be called on a file using the path switch" {
{ Get-ItemProperty -Path $testfile } | Should -Not -Throw
}
It "Should be able to access a property using the Path and name switches" {
{ Get-ItemProperty -Path $testfile -Name fullname } | Should -Not -Throw
$output = Get-ItemProperty -Path $testfile -Name fullname
$output.PSPath | Should -Not -BeNullOrEmpty
$output.PSDrive | Should -Be $testprovider
$output.PSProvider.Name | Should -Be "FileSystem"
}
It "Should be able to use the gp alias without error" {
{ gp . } | Should -Not -Throw
{ gp .. } | Should -Not -Throw
}
It "Should have the same results between alias and cmdlet" {
$alias = gp -Path $testfile -Name fullname
$cmdlet = Get-ItemProperty -Path $testfile -Name fullname
$alias.PSPath | Should -Be $cmdlet.PSPath
$alias.PSDrive | Should -Be $cmdlet.PSDrive
$alias.PSProvider.Name | Should -Be $cmdlet.PSProvider.Name
}
}
|