Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
Get-Verb.Tests.ps166 linesDownload Raw Back to Microsoft.PowerShell.Utility
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "Get-Verb" -Tags "CI" {4 5    It "Should get a list of Verbs" {6        Get-Verb | Should -Not -BeNullOrEmpty7    }8 9    It "Should get a specific verb" {10        @(Get-Verb -verb Add).Count | Should -Be 111        @(Get-Verb -verb Add -Group Common).Count | Should -Be 112    }13 14    It "Should get a specific group" {15        (Get-Verb -Group Common).Group | Sort-Object -Unique | Should -Be Common16    }17 18    It "Should not return duplicate Verbs with Verb paramater" {19        $dups = Get-Verb -verb Add,ad*,a*20        $unique = $dups |21            Select-Object -Property * -Unique22        $dups.Count | Should -Be $unique.Count23    }24 25    It "Should not return duplicate Verbs with Group paramater" {26        $dupVerbs = Get-Verb -Group Data,Data27        $uniqueVerbs = $dupVerbs |28            Select-Object -Property * -Unique29        $dupVerbs.Count | Should -Be $uniqueVerbs.Count30    }31 32    It "Should filter using the Verb parameter" {33        Get-Verb -verb fakeVerbNeverExists | Should -BeNullOrEmpty34    }35 36    It "Should not accept Groups that are not in the validate set" {37        { Get-Verb -Group FakeGroupNeverExists -ErrorAction Stop } |38            Should -Throw -ErrorId 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetVerbCommand'39    }40 41    It "Accept all valid verb groups" {42        $groups = ([System.Reflection.IntrospectionExtensions]::GetTypeInfo([PSObject]).Assembly.ExportedTypes |43            Where-Object {$_.Name -match '^Verbs.'} |44            Select-Object -Property @{Name='VerbGroup';Expression={$_.Name.Substring(5)}}).VerbGroup45        ForEach($group in $groups)46        {47            {Get-Verb -Group $group} | Should -Not -Throw48        }49    }50 51    It "Should not have verbs without descriptions" {52        $noDescVerbs = (Get-Verb | Where-Object { [string]::IsNullOrEmpty($_.Description) }).Verb -join ", "53        $noDescVerbs | Should -BeNullOrEmpty54    }55 56    It "Should not have verbs without alias prefixes" {57        $noPrefixVerbs = (Get-Verb | Where-Object { [string]::IsNullOrEmpty($_.AliasPrefix) }).Verb -join ", "58        $noPrefixVerbs | Should -BeNullOrEmpty59    }60 61    It "Should not have duplicate alias prefixes" {62        $dupPrefixVerbs = ((Get-Verb | Group-Object -Property AliasPrefix | Where-Object Count -GT 1).Group).Verb -join ", "63        $dupPrefixVerbs | Should -BeNullOrEmpty64    }65}66