Skip to content

fix: succeed for empty expected collection in Contains#648

Merged
vbreuss merged 1 commit intomainfrom
topic/fix-empty-expected-collection-for-contains
Jun 21, 2025
Merged

fix: succeed for empty expected collection in Contains#648
vbreuss merged 1 commit intomainfrom
topic/fix-empty-expected-collection-for-contains

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jun 21, 2025

When checking that a collection contains an empty expected collection, it should succeed.

When checking that a collection contains an empty expected collection, it should succeed.
@vbreuss vbreuss self-assigned this Jun 21, 2025
Copilot AI review requested due to automatic review settings June 21, 2025 09:57
@vbreuss vbreuss added the bug Something isn't working label Jun 21, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that calling Contains with an empty expected collection always succeeds by updating the matching logic and adding corresponding tests.

  • Added tests (WhenExpectedIsEmpty_ShouldSucceed) for empty expected collections across all Contains variants, plus null-expected failure tests.
  • Updated CollectionMatchOptions.MissingItemsError to early-exit when the expected collection is empty.
  • Adjusted the build pipeline scope to CoreOnly.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
Tests/aweXpect.Tests/Collections/ThatEnumerable.Contains.CollectionTests.cs Added empty-expected and null-expected tests for all Contains overloads
Tests/aweXpect.Tests/Collections/ThatAsyncEnumerable.Contains.CollectionTests.cs Added empty-expected and null-expected tests for async enumerable Contains
Source/aweXpect.Core/Options/CollectionMatchOptions.cs Early return in MissingItemsError when expected total is zero
Pipeline/Build.cs Changed BuildScope from Default to CoreOnly in build script
Comments suppressed due to low confidence (2)

Source/aweXpect.Core/Options/CollectionMatchOptions.cs:187

  • [nitpick] Add a brief comment explaining that this guard handles the empty expected collection case and prevents an erroneous "all missing" error.
		if (total == 0)

Pipeline/Build.cs:22

  • [nitpick] This build-scope change appears unrelated to the Contains fix. Consider moving pipeline configuration updates into a separate PR to keep concerns isolated.
	readonly BuildScope BuildScope = BuildScope.CoreOnly;

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

    4 files   -     34      4 suites   - 34   19s ⏱️ - 2m 26s
  888 tests  - 12 742    887 ✅  - 12 741  1 💤  - 1  0 ❌ ±0 
2 550 runs   - 35 388  2 549 ✅  - 35 387  1 💤  - 1  0 ❌ ±0 

Results for commit 3937ab1. ± Comparison against base commit e50b985.

This pull request removes 12796 and adds 54 tests. Note that renamed tests count towards both.
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenAwaited_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenAwaited_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_ShouldBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_WithoutReturnValue_ShouldBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_WithoutReturnValue_WithVerifyInMethod_ShouldStillBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedStatically_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedStatically_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedWithStaticUsing_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedWithStaticUsing_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerified_ShouldNotBeFlagged
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message22d15140-5b08-4f07-85e0-ecf225d71d12")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messaged64d9779-f921-4a9e-88a5-4a633ab20457")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagedea64b0b-05cd-4822-99bc-685c10737b28")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message961b5438-74da-4c91-b2ce-a64d0949ec3d")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message9924efcb-2345-45bd-8a58-7d8e3c2f43a2")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messagea4aa4e4c-22c8-481c-9677-f6ec52bae310")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore40a4912c-0013-4646-8ba7-412917d04d11")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnorebff3c936-c07b-4acb-89bd-163ad9800cfd")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnorecc012a19-2ba9-4cdf-9034-ed05cb88d114")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reason8a65f8f6-f0f9-4f15-ab52-0698d388f77c")
…

@vbreuss vbreuss merged commit 56d4abf into main Jun 21, 2025
13 checks passed
@vbreuss vbreuss deleted the topic/fix-empty-expected-collection-for-contains branch June 21, 2025 10:09
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants