Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/Get-ItemProperty.Tests.ps1
T

52 lines
1.7 KiB
PowerShell
Raw Normal View History

2016-07-25 14:01:41 -07:00
Describe "Get-ItemProperty" -Tags "CI" {
$currentDirectory = Split-Path $PSScriptRoot -Leaf
$parentDirectory = Split-Path (Join-Path -Path $PSScriptRoot -ChildPath "..") -Leaf
2016-02-05 08:53:44 -08:00
$tempDirectory = $TestDrive
$testprovider = (Get-Item $tempDirectory).PSDrive.Name
2015-12-28 11:05:48 -08:00
2016-02-05 08:53:44 -08:00
$testfile = Join-Path -Path $tempDirectory -ChildPath testfile1
2015-10-09 12:01:16 -07:00
New-Item $testfile -ItemType file -Force
It "Should be able to be called on in the current directory" {
$(Get-ItemProperty $PSScriptRoot).Name | Should Be $currentDirectory
2015-10-09 12:01:16 -07:00
}
It "Should be able to be called on a parent directory" {
(Get-ItemProperty $PSScriptRoot/..).Name | Should Be $parentDirectory
2015-10-09 12:01:16 -07:00
}
It "Should be able to be called on a directory using the path switch" {
{ Get-ItemProperty -Path $tempDirectory } | Should Not Throw
2015-10-09 12:01:16 -07:00
}
It "Should be able to be called on a file using the path switch" {
{ Get-ItemProperty -Path $testfile } | Should Not Throw
2015-10-09 12:01:16 -07:00
}
It "Should be able to access a property using the Path and name switches" {
{ Get-ItemProperty -Path $testfile -Name fullname } | Should Not Throw
2015-10-09 12:01:16 -07:00
$output = Get-ItemProperty -Path $testfile -Name fullname
2015-10-09 12:01:16 -07:00
$output.PSPath | Should Not BeNullOrEmpty
2015-10-09 12:01:16 -07:00
$output.PSDrive | Should Be $testprovider
2015-10-09 12:01:16 -07:00
$output.PSProvider.Name | Should Be "FileSystem"
2015-10-09 12:01:16 -07:00
}
It "Should be able to use the gp alias without error" {
{ gp . } | Should Not Throw
{ gp .. } | Should Not Throw
2015-10-09 12:01:16 -07:00
}
It "Should have the same results between alias and cmdlet" {
$alias = gp -Path $testfile -Name fullname
$cmdlet = Get-ItemProperty -Path $testfile -Name fullname
2015-10-09 12:01:16 -07:00
$alias.PSPath | Should Be $cmdlet.PSPath
$alias.PSDrive | Should Be $cmdlet.PSDrive
$alias.PSProvider.Name | Should Be $cmdlet.PSProvider.Name
2015-10-09 12:01:16 -07:00
}
}