/
AboutCompareObject.Koans.ps1
33 lines (30 loc) · 1.19 KB
/
AboutCompareObject.Koans.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using module PSKoans
[Koan(Position = 204)]
param()
<#
Compare-Object
Compare-Object is primarily for comparing collections of objects rather than individual
items, and is usually used to display data comparisons to the user.
#>
Describe 'Compare-Object' {
It 'compares collections of objects' {
$Comparison = @{
ReferenceObject = 'this', 'is', 'the', 'reference'
DifferenceObject = 'these', 'is', 'the', 'difference'
}
$CompareData = Compare-Object @Comparison
'__' | Should -Be $CompareData[0].InputObject
'__' | Should -Be $CompareData[0].SideIndicator
$CompareData[0] | Should -BeOfType __
}
It 'can display items that occur in both sets' {
# By default, items that are the same in both collections are hidden.
$Comparison = @{
ReferenceObject = 'this', 'is', 'the', 'reference'
DifferenceObject = 'these', 'is', 'the', 'difference'
}
$CompareData = Compare-Object @Comparison -IncludeEqual
$CompareData.SideIndicator -contains '==' | Should -BeTrue
'__' | Should -Be $CompareData.Where{$_.InputObject -eq 'the'}.SideIndicator
}
}