Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,13 @@ private void Emit(OrderByPropertyEntry entry, string sideIndicator)
#region Overrides

/// <summary>
/// If the parameter 'ExcludeDifferent' is present, then we need to turn on the
/// 'IncludeEqual' switch unless it's turned off by the user specifically.
/// If the parameter 'ExcludeDifferent' is present, then the 'IncludeEqual'
/// switch is turned on unless it's turned off by the user specifically.
/// </summary>
protected override void BeginProcessing()
{
if (ExcludeDifferent)
{
if (_isIncludeEqualSpecified == false)
{
return;
}

if (_isIncludeEqualSpecified && !_includeEqual)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ Describe "Compare-Object" -Tags "CI" {
{ Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $anonexistentvariable } | Should -Throw
}

It "Should give a 0 array when using excludedifferent switch without also using the includeequal switch" {
$actualOutput = Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $(Get-Content $file4) -ExcludeDifferent
It "Should only display equal lines when excludeDifferent switch is used without the includeequal switch" {
$actualOutput = Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $(Get-Content $file4) -ExcludeDifferent

$actualOutput.Length | Should -Be 0
$actualOutput.Length | Should -Be 2
}

It "Should only display equal lines when excludeDifferent switch is used alongside the includeequal switch" {
Expand All @@ -88,6 +88,12 @@ Describe "Compare-Object" -Tags "CI" {
$actualOutput.Length | Should -Be 2
}

It "Should give a 0 array when using excludedifferent switch when also setting the includeequal switch to false" {
$actualOutput = Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $(Get-Content $file4) -ExcludeDifferent -IncludeEqual:$false

$actualOutput.Length | Should -Be 0
}

It "Should be able to pass objects to pipeline using the passthru switch" {
{ Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $(Get-Content $file4) -Passthru | Format-Wide } | Should -Not -Throw
}
Expand Down