mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Added -CaseInsensitive switch parameter to Select-Object & Get-Unique cmdlets (#19683)
* Added Select-Object CaseInsensitive parameter and tests * Added Get-Unique CaseInsensitive parameter and tests * Fix codefactor issue * Add named arguements * Remove comments
This commit is contained in:
1 parent
828b541d09
commit
836c0c580b
4 files changed
+53
-5
No files matched your search
@@ -1,8 +1,12 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
Describe "Get-Unique DRT Unit Tests" -Tags "CI" {
|
||||
It "Command get-unique works with AsString switch" {
|
||||
|
||||
BeforeAll {
|
||||
$inputArray = "aa","aa","Aa","ba","BA","BA"
|
||||
}
|
||||
|
||||
It "Command get-unique works with AsString switch" {
|
||||
$results = $inputArray | Get-Unique -AsString
|
||||
|
||||
$results.Length | Should -Be 4
|
||||
@@ -17,6 +21,18 @@ Describe "Get-Unique DRT Unit Tests" -Tags "CI" {
|
||||
$results[2] | Should -BeOfType System.String
|
||||
$results[3] | Should -BeOfType System.String
|
||||
}
|
||||
|
||||
It "Command get-unique works with AsString and CaseInsensitive switches" {
|
||||
$results = $inputArray | Get-Unique -AsString -CaseInsensitive
|
||||
|
||||
$results.Length | Should -Be 2
|
||||
|
||||
$results[0] | Should -BeExactly "aa"
|
||||
$results[1] | Should -BeExactly "ba"
|
||||
|
||||
$results[0] | Should -BeOfType System.String
|
||||
$results[1] | Should -BeOfType System.String
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Get-Unique" -Tags "CI" {
|
||||
@@ -26,6 +42,8 @@ Describe "Get-Unique" -Tags "CI" {
|
||||
$expectedOutput1 = 1,2,3,4,5
|
||||
$collection = "a", "b", "b", "d"
|
||||
$expectedOutput2 = "a", "b", "d"
|
||||
$collection2 = "a","A", "b", "B"
|
||||
$expectedOutput3 = "a", "b"
|
||||
}
|
||||
|
||||
It "Should be able to use the Get-Unique cmdlet without error with inputObject switch" {
|
||||
@@ -61,4 +79,9 @@ Describe "Get-Unique" -Tags "CI" {
|
||||
$actual = $collection | Get-Unique
|
||||
$(Compare-Object $actual $expectedOutput2 -SyncWindow 0).Length | Should -Be 0
|
||||
}
|
||||
|
||||
It "Should get the unique strings when CaseInsensitive switch is used" {
|
||||
$actual = $collection2 | Get-Unique -CaseInsensitive
|
||||
$(Compare-Object $actual $expectedOutput3 -SyncWindow 0).Length | Should -Be 0
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,13 @@ Describe "Select-Object" -Tags "CI" {
|
||||
$result | Should -Be $expected
|
||||
}
|
||||
|
||||
It "Should work work correctly with Unique and CaseInsensitive parameter" {
|
||||
$result = "abc", "Abc" | Select-Object -Unique -CaseInsensitive
|
||||
|
||||
$result.Count | Should -Be 1
|
||||
$result | Should -Be "abc"
|
||||
}
|
||||
|
||||
It "Should return correct object with Skip parameter" {
|
||||
$result = $dirObject | Select-Object -Skip $TestLength
|
||||
|
||||
|
||||
Reference in new issue
Block a user