Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Verb.Tests.ps1
T
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00

71 lines
2.5 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Get-Verb" -Tags "CI" {
It "Should get a list of Verbs" {
Get-Verb | Should not be $null
}
It "Should get a specific verb" {
@(Get-Verb -Verb Add).Count | Should be 1
@(Get-Verb -Verb Add -Group Common).Count | Should be 1
}
It "Should get a specific group" {
(Get-Verb -Group Common).Group | Sort-Object -Unique | Should be Common
}
It "Should not return duplicate Verbs with Verb paramater" {
$dups = Get-Verb -Verb Add,ad*,a*
$unique = $dups |
Select-Object -Property * -Unique
$dups.Count | Should be $unique.Count
}
It "Should not return duplicate Verbs with Group paramater" {
$dupVerbs = Get-Verb -Group Data,Data
$uniqueVerbs = $dupVerbs |
Select-Object -Property * -Unique
$dupVerbs.Count | Should be $uniqueVerbs.Count
}
It "Should filter using the Verb parameter" {
Get-Verb -Verb fakeVerbNeverExists | Should BeNullOrEmpty
}
It "Should not accept Groups that are not in the validate set" {
try{
Get-Verb -Group FakeGroupNeverExists -ErrorAction Stop
throw "Expected error did not occur"
}
Catch{
$PSItem.FullyQualifiedErrorId | Should be 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetVerbCommand'
}
}
It "Accept all valid verb groups" {
$groups = ([System.Reflection.IntrospectionExtensions]::GetTypeInfo([PSObject]).Assembly.ExportedTypes |
Where-Object {$_.Name -match '^Verbs.'} |
Select-Object -Property @{Name='VerbGroup';Expression={$_.Name.Substring(5)}}).VerbGroup
ForEach($group in $groups)
{
{Get-Verb -Group $group} | Should Not Throw
}
}
It "Should not have verbs without descriptions" {
$noDescVerbs = (Get-Verb | Where-Object { [string]::IsNullOrEmpty($_.Description) }).Verb -join ", "
$noDescVerbs | Should BeNullOrEmpty
}
It "Should not have verbs without alias prefixes" {
$noPrefixVerbs = (Get-Verb | Where-Object { [string]::IsNullOrEmpty($_.AliasPrefix) }).Verb -join ", "
$noPrefixVerbs | Should BeNullOrEmpty
}
It "Should not have duplicate alias prefixes" {
$dupPrefixVerbs = ((Get-Verb | Group-Object -Property AliasPrefix | Where-Object Count -gt 1).Group).Verb -join ", "
$dupPrefixVerbs | Should BeNullOrEmpty
}
}