Skip to content

feat: negate IsContainedIn and Contains#627

Merged
vbreuss merged 2 commits intomainfrom
topic/negate-contains-iscontainedin
May 23, 2025
Merged

feat: negate IsContainedIn and Contains#627
vbreuss merged 2 commits intomainfrom
topic/negate-contains-iscontainedin

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 23, 2025

Add negated overloads IsNotContainedIn and DoesNotContain for collections.

Add negated overloads `IsNotContainedIn` and `DoesNotContain` for collections.
@vbreuss vbreuss self-assigned this May 23, 2025
Copilot AI review requested due to automatic review settings May 23, 2025 20:17
@vbreuss vbreuss added the enhancement New feature or request label May 23, 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

Adds negated collection expectations and updates error-message formatting to clearly separate the actual “Collection” and the “Expected” values in negated assertions.

  • Introduce DoesNotContain and IsNotContainedIn overloads for both IEnumerable<T> and IAsyncEnumerable<T>.
  • Enhance constraint builders to add explicit expected‐value contexts and streamline negated message output.
  • Update tests and API snapshots to assert the new multi‐section formatting and reflect the new overloads.

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/aweXpect.Tests/Collections/ThatEnumerable.IsNotEqualTo.Tests.cs Updated expected error message formatting to include separate “Collection” and “Expected” sections
Tests/aweXpect.Tests/Collections/ThatEnumerable.IsEqualTo.WithinTests.cs Added “Expected” context lines to Within‐tolerance tests
Tests/aweXpect.Tests/Collections/ThatEnumerable.DoesNotContain.Tests.cs Changed class to partial and removed null‐predicate tests
Tests/aweXpect.Tests/Collections/ThatAsyncEnumerable.IsNotEqualTo.WithinTests.cs Added “Expected” context lines to async Within‐tolerance tests
Tests/aweXpect.Tests/Collections/ThatAsyncEnumerable.IsNotEqualTo.Tests.cs Added “Expected” context lines to async not‐equal tests
Tests/aweXpect.Tests/Collections/ThatAsyncEnumerable.IsEqualTo.WithinTests.cs Added “Expected” context lines to async equality Within‐tests
Tests/aweXpect.Tests/Collections/ThatAsyncEnumerable.DoesNotContain.Tests.cs Changed class to partial and removed null‐predicate tests
Tests/aweXpect.Api.Tests/Expected/aweXpect_netstandard2.0.txt Added API signatures for DoesNotContain and IsNotContainedIn overloads
Tests/aweXpect.Api.Tests/Expected/aweXpect_net8.0.txt Added API signatures for async DoesNotContain and IsNotContainedIn overloads
Source/aweXpect/That/Collections/ThatEnumerable.cs Added expected‐value context support and simplified negated result formatting
Source/aweXpect/That/Collections/ThatEnumerable.IsContainedIn.cs Introduced IsNotContainedIn overloads for IEnumerable<T>
Source/aweXpect/That/Collections/ThatEnumerable.Contains.cs Introduced DoesNotContain overloads for IEnumerable<T>
Source/aweXpect/That/Collections/ThatAsyncEnumerable.cs Added expected‐value context support to async enumerable matcher and simplified deviation error text
Source/aweXpect/That/Collections/ThatAsyncEnumerable.IsContainedIn.cs Introduced IsNotContainedIn overloads for IAsyncEnumerable<T>
Source/aweXpect/That/Collections/ThatAsyncEnumerable.Contains.cs Introduced DoesNotContain overloads for IAsyncEnumerable<T>
Docs/pages/docs/expectations/07-collections.md Documented DoesNotContain and IsNotContainedIn expectations
Comments suppressed due to low confidence (2)

Tests/aweXpect.Tests/Collections/ThatEnumerable.DoesNotContain.Tests.cs:926

  • The null‐predicate validation test for DoesNotContain was removed, leaving no coverage to ensure passing a null predicate throws the expected exception. Consider reintroducing a test for null predicate behavior.
[Fact]

Tests/aweXpect.Tests/Collections/ThatAsyncEnumerable.DoesNotContain.Tests.cs:888

  • The null‐predicate validation test for async DoesNotContain was removed, so there's no test ensuring a null predicate triggers the correct exception. Consider adding it back.
[Fact]

Comment thread Source/aweXpect/That/Collections/ThatAsyncEnumerable.IsContainedIn.cs Outdated
Comment thread Source/aweXpect/That/Collections/ThatEnumerable.cs
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2025

Test Results

    14 files   -    24      14 suites   - 24   2m 22s ⏱️ +4s
11 513 tests +  509  11 511 ✅ +  509  2 💤 ±0  0 ❌ ±0 
31 581 runs  +1 527  31 579 ✅ +1 527  2 💤 ±0  0 ❌ ±0 

Results for commit 9fdf1b0. ± Comparison against base commit 62a44eb.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.14.0, Ubuntu 24.04.2 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.410
[Host] : .NET 8.0.16 (8.0.1625.21506), X64 RyuJIT AVX2

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 194.9 ns 3.03 ns 2.68 ns 0.0281 - 472 B
Bool_FluentAssertions 238.6 ns 3.52 ns 3.30 ns 0.0567 - 952 B
Bool_TUnit 910.6 ns 4.99 ns 4.66 ns 0.1440 - 2416 B
Equivalency_aweXpect 290,048.3 ns 1,230.38 ns 1,027.42 ns 16.6016 0.4883 284940 B
Equivalency_FluentAssertions 2,197,377.9 ns 15,676.71 ns 14,664.01 ns 273.4375 46.8750 4584416 B
Equivalency_TUnit 654,189.6 ns 3,526.20 ns 3,298.41 ns 51.7578 2.9297 866777 B
Int_GreaterThan_aweXpect 225.7 ns 2.84 ns 2.52 ns 0.0467 - 784 B
Int_GreaterThan_FluentAssertions 238.7 ns 3.25 ns 2.88 ns 0.0730 - 1224 B
Int_GreaterThan_TUnit 1,199.6 ns 9.23 ns 8.63 ns 0.1774 - 2992 B
ItemsCount_AtLeast_aweXpect 449.2 ns 5.64 ns 5.28 ns 0.0830 - 1392 B
ItemsCount_AtLeast_FluentAssertions 473.4 ns 3.79 ns 2.96 ns 0.1197 - 2008 B
ItemsCount_AtLeast_TUnit 21,848.8 ns 84.10 ns 74.55 ns 1.6174 - 27488 B
String_aweXpect 337.8 ns 4.48 ns 3.74 ns 0.0672 - 1128 B
String_FluentAssertions 463.8 ns 3.46 ns 3.23 ns 0.1292 - 2168 B
String_TUnit 1,299.6 ns 11.55 ns 10.24 ns 0.1850 - 3096 B
StringArray_aweXpect 1,318.8 ns 8.04 ns 7.52 ns 0.1602 - 2712 B
StringArray_FluentAssertions 1,349.4 ns 14.19 ns 13.27 ns 0.2480 - 4152 B
StringArray_TUnit 2,844.6 ns 19.73 ns 17.49 ns 0.2708 - 4576 B
StringArrayInAnyOrder_aweXpect 1,469.0 ns 13.30 ns 12.44 ns 0.1717 - 2872 B
StringArrayInAnyOrder_FluentAssertions 151,349.2 ns 1,081.66 ns 1,011.79 ns 3.4180 - 63351 B
StringArrayInAnyOrder_TUnit 4,650.4 ns 42.43 ns 37.62 ns 0.3967 - 6744 B

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2025

👽 Mutation Results

Mutation testing badge

aweXpect

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants
That/Collections/ThatAsyncEnumerable.Contains.cs 92.13% 81 2 1 5 26 3 82 7 118
That/Collections/ThatAsyncEnumerable.cs 79.73% 118 7 0 23 48 38 118 30 234
That/Collections/ThatAsyncEnumerable.IsContainedIn.cs 100.00% 4 0 0 0 0 0 4 0 4
That/Collections/ThatEnumerable.Contains.cs 91.67% 66 1 0 5 23 3 66 6 98
That/Collections/ThatEnumerable.cs 87.23% 121 4 2 14 40 6 123 18 187
That/Collections/ThatEnumerable.IsContainedIn.cs 100.00% 4 0 0 0 0 0 4 0 4

The final mutation score is 86.68%

Coverage Thresholds: high:80 low:60 break:0

aweXpect.Core

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants

The final mutation score is NaN%

Coverage Thresholds: high:80 low:60 break:0

…edIn.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vbreuss vbreuss enabled auto-merge (squash) May 23, 2025 20:42
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss merged commit 3b46875 into main May 23, 2025
13 checks passed
@vbreuss vbreuss deleted the topic/negate-contains-iscontainedin branch May 23, 2025 21:03
github-actions Bot added a commit that referenced this pull request May 23, 2025
github-actions Bot added a commit that referenced this pull request May 23, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.15.0.

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

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants