2016-03-04 23:48:30 +01:00
|
|
|
Describe "Export-Alias" {
|
|
|
|
$testAliasDirectory = Join-Path -Path $TestDrive -ChildPath ExportAliasTestDirectory
|
|
|
|
$testAliases = "TestAliases"
|
|
|
|
$fulltestpath = Join-Path -Path $($testAliasDirectory) -ChildPath $($testAliases)
|
|
|
|
|
|
|
|
BeforeEach {
|
2016-03-04 23:52:27 +01:00
|
|
|
New-Item -Path $testAliasDirectory -ItemType Directory -Force
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to create a file in the specified location"{
|
2016-03-04 23:52:27 +01:00
|
|
|
Export-Alias $fulltestpath
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
Test-Path $fulltestpath | Should be $true
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should create a file with the list of aliases that match the expected list" {
|
2016-03-04 23:52:27 +01:00
|
|
|
Export-Alias $fulltestpath
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
Test-Path $fulltestpath | Should Be $true
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual = Get-Content $fulltestpath | Sort
|
|
|
|
$expected = $(Get-Command -CommandType Alias)
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
for ( $i=0; $i -lt $expected.Length; $i++)
|
|
|
|
{
|
|
|
|
# We loop through the expected list and not the other because the output writes some comments to the file.
|
|
|
|
$expected[$i] | Should Match $actual[$i].Name
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Remove-Item -Path $testAliasDirectory -Recurse -Force
|
|
|
|
}
|