|
| 1 | +Describe "Basic Validation of Alias Provider" -Tags "CI" { |
| 2 | + BeforeAll { |
| 3 | + $testAliasName = 'TestAlias' |
| 4 | + $testAliasValue = 'Get-Date' |
| 5 | + } |
| 6 | + |
| 7 | + BeforeEach { |
| 8 | + New-Item -Path Alias:\ -Name $testAliasName -Value $testAliasValue > $null |
| 9 | + } |
| 10 | + |
| 11 | + AfterEach { |
| 12 | + Remove-Item -Path "Alias:\${testAliasName}" -ErrorAction SilentlyContinue |
| 13 | + } |
| 14 | + |
| 15 | + It "Test number of alias not Zero" { |
| 16 | + $aliases = Get-ChildItem Alias:\ |
| 17 | + $aliases.Count | Should Not Be 0 |
| 18 | + } |
| 19 | + |
| 20 | + It "Test alias 'dir'" { |
| 21 | + $dirAlias = Get-Item Alias:\dir |
| 22 | + $dirAlias.CommandType | Should Be 'Alias' |
| 23 | + $dirAlias.Name | Should Be 'dir' |
| 24 | + $dirAlias.Definition | Should Be 'Get-ChildItem' |
| 25 | + } |
| 26 | + |
| 27 | + It "Test creating new alias" { |
| 28 | + $newAlias = New-Item -Path Alias:\ -Name 'NewTestAlias' -Value $testAliasValue |
| 29 | + try { |
| 30 | + $newAlias.CommandType | Should Be 'Alias' |
| 31 | + $newAlias.Name | Should Be 'NewTestAlias' |
| 32 | + $newAlias.Definition | Should Be $testAliasValue |
| 33 | + } |
| 34 | + finally { |
| 35 | + Remove-Item -Path 'Alias:\NewTestAlias' -ErrorAction SilentlyContinue |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + It "Test get-item on alias provider" { |
| 40 | + $alias = Get-Item -Path "Alias:\${testAliasName}" |
| 41 | + $alias.CommandType | Should Be 'Alias' |
| 42 | + $alias.Name | Should Be $testAliasName |
| 43 | + $alias.Definition | Should Be $testAliasValue |
| 44 | + } |
| 45 | + |
| 46 | + It "Test test-path on alias provider" { |
| 47 | + $aliasExists = Test-Path Alias:\testAlias |
| 48 | + $aliasExists | Should Be $true |
| 49 | + } |
| 50 | + |
| 51 | + It "Test executing the new alias" { |
| 52 | + $result = testAlias |
| 53 | + $result.GetType().Name | Should Be 'DateTime' |
| 54 | + } |
| 55 | +} |
0 commit comments