2016-03-04 23:48:30 +01:00
|
|
|
Describe "Get-Unique" {
|
2015-10-06 21:29:40 +02:00
|
|
|
$sortedList1 = 1,2,2,3,3,4,5
|
|
|
|
It "Should be able to use the Get-Unique cmdlet without error with inputObject switch" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ Get-Unique -InputObject $sortedList1 } | Should Not Throw
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to uset the gu alias without error" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ gu -InputObject $sortedList1 } | Should Not Throw
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should output an array" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-Unique -InputObject $sortedList1).GetType().BaseType | Should Be Array
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should output an array of unchanged items when the InputObject switch is used" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual = Get-Unique -InputObject $sortedList1
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual[0] | Should Be $sortedList1[0]
|
|
|
|
$actual[1] | Should Be $sortedList1[1]
|
|
|
|
$actual[2] | Should Be $sortedList1[2]
|
|
|
|
$actual[3] | Should Be $sortedList1[3]
|
|
|
|
$actual[4] | Should Be $sortedList1[4]
|
|
|
|
$actual[5] | Should Be $sortedList1[5]
|
|
|
|
$actual[6] | Should Be $sortedList1[6]
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual.Length | Should Be 7
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should accept piped input" {
|
2016-03-04 23:52:27 +01:00
|
|
|
{ $actualOutput = $sortedList1 | Get-Unique } | Should Not Throw
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should have the expected output when piped input is used" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$actualOutput = $sortedList1 | Get-Unique
|
|
|
|
$expectedOutput = 1,2,3,4,5
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actualOutput.Length | Should Be $expectedOutput.Length
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actualOutput[0] | Should Be $expectedOutput[0]
|
|
|
|
$actualOutput[1] | Should Be $expectedOutput[1]
|
|
|
|
$actualOutput[2] | Should Be $expectedOutput[2]
|
|
|
|
$actualOutput[3] | Should Be $expectedOutput[3]
|
|
|
|
$actualOutput[4] | Should Be $expectedOutput[4]
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to input a collection in the inputObject switch" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$collection = "a", "b", "b", "d"
|
|
|
|
$actual = Get-Unique -InputObject $collection
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual.Length | Should Be $collection.Length
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual[0] | Should Be $collection[0]
|
|
|
|
$actual[1] | Should Be $collection[1]
|
|
|
|
$actual[2] | Should Be $collection[2]
|
|
|
|
$actual[3] | Should Be $collection[3]
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should get the unique items when piped collection input is used" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$collection = "a", "b", "b", "d"
|
|
|
|
$expectedOutput = "a", "b", "d"
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual = Get-Unique -InputObject $collection
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual.Length | Should Be $collection.Length
|
2015-10-06 21:29:40 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$actual[0] | Should Be $collection[0]
|
|
|
|
$actual[1] | Should Be $collection[1]
|
|
|
|
$actual[2] | Should Be $collection[2]
|
2015-10-06 21:29:40 +02:00
|
|
|
}
|
|
|
|
}
|