From 14231c96e75951e10485d3691520f3dbae5da307 Mon Sep 17 00:00:00 2001 From: TingLiu6 Date: Mon, 25 Apr 2016 00:34:00 -0700 Subject: [PATCH 1/2] Add Unit Test for Get-Unique --- test/powershell/Get-Unique.Tests.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/powershell/Get-Unique.Tests.ps1 b/test/powershell/Get-Unique.Tests.ps1 index 8eade4134..7182d366c 100644 --- a/test/powershell/Get-Unique.Tests.ps1 +++ b/test/powershell/Get-Unique.Tests.ps1 @@ -1,3 +1,22 @@ +Describe "Get-Unique DRT Unit Tests" -Tags DRT{ + It "Command get-unique works with AsString switch" { + $inputArray = "aa","aa","Aa","ba","BA","BA" + $results = $inputArray | Get-Unique -AsString + + $results.Length | Should Be 4 + + $results[0] | Should Be "aa" + $results[1] | Should Be "Aa" + $results[2] | Should Be "ba" + $results[3] | Should Be "BA" + + $results[0].GetType().FullName | Should be System.String + $results[1].GetType().FullName | Should be System.String + $results[2].GetType().FullName | Should be System.String + $results[3].GetType().FullName | Should be System.String + } +} + Describe "Get-Unique" { $sortedList1 = 1,2,2,3,3,4,5 It "Should be able to use the Get-Unique cmdlet without error with inputObject switch" { From 187013985ad6d379097f6190ef8fc953b58c0d52 Mon Sep 17 00:00:00 2001 From: TingLiu6 Date: Wed, 4 May 2016 22:51:34 -0700 Subject: [PATCH 2/2] Fix the CR issue for Get-Unique --- test/powershell/Get-Unique.Tests.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/powershell/Get-Unique.Tests.ps1 b/test/powershell/Get-Unique.Tests.ps1 index 7182d366c..2b5688e90 100644 --- a/test/powershell/Get-Unique.Tests.ps1 +++ b/test/powershell/Get-Unique.Tests.ps1 @@ -78,12 +78,12 @@ Describe "Get-Unique" { $collection = "a", "b", "b", "d" $expectedOutput = "a", "b", "d" - $actual = Get-Unique -InputObject $collection + $actual = $collection | Get-Unique - $actual.Length | Should Be $collection.Length + $actual.Length | Should Be $expectedOutput.Length - $actual[0] | Should Be $collection[0] - $actual[1] | Should Be $collection[1] - $actual[2] | Should Be $collection[2] + $actual[0] | Should Be $expectedOutput[0] + $actual[1] | Should Be $expectedOutput[1] + $actual[2] | Should Be $expectedOutput[2] } }