mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
This restructuring moves tests to a directory name which matches the module in which the cmdlet resides which should improve the discoverability of a specific test. For tests which are not about cmdlets in a module, new directories have been created to make those tests easier to find as well
53 lines
1.7 KiB
PowerShell
53 lines
1.7 KiB
PowerShell
Describe "Get-ItemProperty" {
|
|
$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 Be $currentDirectory
|
|
}
|
|
|
|
It "Should be able to be called on a parent directory" {
|
|
(Get-ItemProperty $PSScriptRoot/..).Name | Should Be $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
|
|
}
|
|
}
|