2015-10-31 01:10:19 +01:00
|
|
|
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
|
|
|
|
|
|
|
Describe "Get-ItemProperty" {
|
|
|
|
|
$currentDirectory = Split-Path $here -Leaf
|
2016-02-05 17:53:44 +01:00
|
|
|
|
$parentDirectory = Split-Path (Join-Path -Path $here -ChildPath "..") -Leaf
|
|
|
|
|
$tempDirectory = $TestDrive
|
|
|
|
|
$testprovider = (Get-Item $tempDirectory).PSDrive.Name
|
2015-12-28 20:05:48 +01:00
|
|
|
|
|
2016-02-05 17:53:44 +01:00
|
|
|
|
$testfile = Join-Path -Path $tempDirectory -ChildPath testfile1
|
2015-10-09 21:01:16 +02:00
|
|
|
|
|
|
|
|
|
New-Item $testfile -ItemType file -Force
|
|
|
|
|
|
|
|
|
|
It "Should be able to be called on in the current directory" {
|
2015-10-31 01:10:19 +01:00
|
|
|
|
$(Get-ItemProperty $here).Name | Should Be $currentDirectory
|
2015-10-09 21:01:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Should be able to be called on a parent directory" {
|
2015-10-31 01:10:19 +01:00
|
|
|
|
(Get-ItemProperty $here/..).Name | Should Be $parentDirectory
|
2015-10-09 21:01:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|