Use new Pester syntax: -Parameter for Pester tests in modules: Microsoft.PowerShell.Utility and Microsoft.WSMan.Management. (#6366)

This commit is contained in:
Klaudia Algiz authored and Travis Plunk committed 2018-03-23 10:26:23 -07:00
1 parent 942832c13a
commit cc3ffd8349
111 files changed
+2491 -3092

No files matched your search

@@ -4,12 +4,12 @@ Describe "Group-Object DRT Unit Tests" -Tags "CI" {
It "Test for CaseSensitive switch" {
$testObject = 'aA', 'aA', 'AA', 'AA'
$results = $testObject | Group-Object -CaseSensitive
$results.Count | Should Be 2
$results.Name.Count | Should Be 2
$results.Group.Count | Should Be 4
$results.Name | Should Be aA,AA
$results.Group | Should Be aA,aA,AA,AA
,$results | Should BeOfType "System.Array"
$results.Count | Should -Be 2
$results.Name.Count | Should -Be 2
$results.Group.Count | Should -Be 4
$results.Name | Should -Be aA,AA
$results.Group | Should -Be aA,aA,AA,AA
,$results | Should -BeOfType "System.Array"
}
}
@@ -20,55 +20,55 @@ Describe "Group-Object" -Tags "CI" {
}
It "Should be called using an object as piped without error with no switches" {
{$testObject | Group-Object } | Should Not Throw
{$testObject | Group-Object } | Should -Not -Throw
}
It "Should be called using the InputObject without error with no other switches" {
{ Group-Object -InputObject $testObject } | Should Not Throw
{ Group-Object -InputObject $testObject } | Should -Not -Throw
}
It "Should return three columns- count, name, and group" {
$actual = Group-Object -InputObject $testObject
$actual.Count | Should BeGreaterThan 0
$actual.Name.Count | Should BeGreaterThan 0
$actual.Group.Count | Should BeGreaterThan 0
$actual.Count | Should -BeGreaterThan 0
$actual.Name.Count | Should -BeGreaterThan 0
$actual.Group.Count | Should -BeGreaterThan 0
}
It "Should use the group alias" {
{ Group-Object -InputObject $testObject } | Should Not Throw
{ Group-Object -InputObject $testObject } | Should -Not -Throw
}
It "Should create a collection when the inputObject parameter is used" {
$actualParam = Group-Object -InputObject $testObject
$actualParam.Group.Gettype().Name | Should Be 'Collection`1'
$actualParam.Group.Gettype().Name | Should -Be 'Collection`1'
}
It "Should return object of 'GroupInfo' type" {
$actualParam = Group-Object -InputObject $testObject
$actualParam | Should BeOfType "Microsoft.PowerShell.Commands.GroupInfo"
$actualParam | Should -BeOfType "Microsoft.PowerShell.Commands.GroupInfo"
}
It "Should output an array when piped input is used" {
$actual = $testObject | Group-Object
,$actual | Should BeOfType "System.Array"
,$actual | Should -BeOfType "System.Array"
}
It "Should have the same output between the group alias and the group-object cmdlet" {
$actualAlias = Group-Object -InputObject $testObject
$actualCmdlet = Group-Object -InputObject $testObject
$actualAlias.Name[0] | Should Be $actualCmdlet.Name[0]
$actualAlias.Group[0] | Should Be $actualCmdlet.Group[0]
$actualAlias.Name[0] | Should -Be $actualCmdlet.Name[0]
$actualAlias.Group[0] | Should -Be $actualCmdlet.Group[0]
}
It "Should be able to use the property switch without error" {
{ $testObject | Group-Object -Property Attributes } | Should Not Throw
{ $testObject | Group-Object -Property Attributes } | Should -Not -Throw
$actual = $testObject | Group-Object -Property Attributes
$actual.Group.Count | Should BeGreaterThan 0
$actual.Group.Count | Should -BeGreaterThan 0
}
It "Should be able to use the property switch on multiple properties without error" {
@@ -76,34 +76,34 @@ Describe "Group-Object" -Tags "CI" {
$actual = $testObject | Group-Object -Property Attributes, Length
$actual.Group.Count | Should BeGreaterThan 0
$actual.Group.Count | Should -BeGreaterThan 0
}
It "Should be able to omit members of a group using the NoElement switch without error" {
{ $testObject | Group-Object -NoElement } | Should Not Throw
{ $testObject | Group-Object -NoElement } | Should -Not -Throw
($testObject | Group-Object -NoElement).Group | Should BeNullOrEmpty
($testObject | Group-Object -NoElement).Group | Should -BeNullOrEmpty
}
It "Should be able to output a hashtable datatype" {
$actual = $testObject | Group-Object -AsHashTable
$actual | Should Not BeNullOrEmpty
$actual | Should BeOfType "System.Collections.Hashtable"
$actual | Should -Not -BeNullOrEmpty
$actual | Should -BeOfType "System.Collections.Hashtable"
}
It "Should be able to access when output as hash table" {
$actual = $testObject | Group-Object -AsHashTable
$actual.Keys | Should Not BeNullOrEmpty
$actual.Keys | Should -Not -BeNullOrEmpty
}
It "Should throw when attempting to use AsString without AsHashTable" {
{ $testObject | Group-Object -AsString } | Should Throw
{ $testObject | Group-Object -AsString } | Should -Throw
}
It "Should not throw error when using AsString when the AsHashTable was added" {
{ $testObject | Group-Object -AsHashTable -AsString } | Should Not Throw
{ $testObject | Group-Object -AsHashTable -AsString } | Should -Not -Throw
}
}
@@ -124,7 +124,7 @@ Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-
$testCulture = "ru-RU"
}
{$testObject | Group-Object -Culture $testCulture } | Should Not Throw
{$testObject | Group-Object -Culture $testCulture } | Should -Not -Throw
}
It "Should accept a culture by hex string LCID" {
@@ -136,7 +136,7 @@ Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-
$testCulture = "0x419"
}
{$testObject | Group-Object -Culture $testCulture } | Should Not Throw
{$testObject | Group-Object -Culture $testCulture } | Should -Not -Throw
}
It "Should accept a culture by int string LCID" {
@@ -148,6 +148,6 @@ Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-
$testCulture = "1049"
}
{$testObject | Group-Object -Culture $testCulture } | Should Not Throw
{$testObject | Group-Object -Culture $testCulture } | Should -Not -Throw
}
}