Files
PowerShell/test/powershell/Set-Location.Tests.ps1
T

68 lines
1.8 KiB
PowerShell
Raw Normal View History

2015-10-23 10:01:44 -07:00
Describe "Set-Location" {
2015-12-01 10:30:27 -08:00
$startDirectory = Get-Location
2015-12-28 11:05:48 -08:00
$isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)
if ($isWindows)
2015-12-01 10:30:27 -08:00
{
2015-12-28 11:05:48 -08:00
$target = "C:\"
2015-12-01 10:30:27 -08:00
}
else
{
2015-12-28 11:05:48 -08:00
$target = "/"
2015-12-01 10:30:27 -08:00
}
2015-10-23 15:33:32 -07:00
2015-12-01 10:30:27 -08:00
It "Should be able to be called without error" {
{ Set-Location $target } | Should Not Throw
}
2015-10-23 15:33:32 -07:00
2015-12-01 10:30:27 -08:00
It "Should be able to be called on different providers" {
{ Set-Location alias: } | Should Not Throw
{ Set-Location env: } | Should Not Throw
}
2015-10-23 15:33:32 -07:00
2015-12-01 10:30:27 -08:00
It "Should be able use the cd alias without error" {
{ cd $target } | Should Not Throw
}
2015-10-23 15:33:32 -07:00
2015-12-01 10:30:27 -08:00
It "Should be able to use the chdir alias without error" {
{ chdir $target } | Should Not Throw
}
2015-10-23 15:33:32 -07:00
2015-12-01 10:30:27 -08:00
It "Should be able to use the sl alias without error" {
{ sl $target } | Should Not Throw
}
2015-10-23 10:01:44 -07:00
2015-12-01 10:30:27 -08:00
It "Should have the correct current location when using the set-location cmdlet" {
Set-Location $startDirectory
2015-10-23 10:01:44 -07:00
2015-12-01 10:30:27 -08:00
$(Get-Location).Path | Should Be $startDirectory.Path
2015-10-23 10:01:44 -07:00
}
2015-12-01 10:30:27 -08:00
It "Should have the correct current location when using the cd alias" {
cd $target
$(Get-Location).Path | Should Be $target
}
It "Should have the correct current location when using the chdir alias" {
chdir $target
$(Get-Location).Path | Should Be $target
}
It "Should have the correct current location when using the chdir alias" {
sl $target
$(Get-Location).Path | Should Be $target
}
It "Should be able to use the Path switch" {
{ Set-Location -Path $target } | Should Not Throw
}
It "Should generate a pathinfo object when using the Passthru switch" {
$(Set-Location $target -PassThru).GetType().Name | Should Be PathInfo
}
Set-Location $startDirectory
2015-10-23 10:01:44 -07:00
}