Skip to content

feat: add Is{Not}EquatableTo#745

Merged
vbreuss merged 2 commits intomainfrom
topic/support-iequatable
Sep 2, 2025
Merged

feat: add Is{Not}EquatableTo#745
vbreuss merged 2 commits intomainfrom
topic/support-iequatable

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Sep 2, 2025

This PR adds new assertion methods IsEquatableTo and IsNotEquatableTo to the aweXpect assertion library for testing equality using the IEquatable<T> interface.


@vbreuss vbreuss self-assigned this Sep 2, 2025
Copilot AI review requested due to automatic review settings September 2, 2025 09:07
@vbreuss vbreuss added the enhancement New feature or request label Sep 2, 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 adds new assertion methods IsEquatableTo and IsNotEquatableTo to the aweXpect assertion library for testing equality using the IEquatable<T> interface.

  • Introduces two generic extension methods that leverage C#'s IEquatable<T> interface for type-safe equality comparisons
  • Adds comprehensive test coverage for both positive and negative assertion scenarios
  • Updates public API surface to include the new methods in both .NET Standard 2.0 and .NET 8.0 targets

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Source/aweXpect/That/ThatGeneric.IsEquatableTo.cs Core implementation of the IsEquatableTo and IsNotEquatableTo extension methods with constraint logic
Tests/aweXpect.Tests/ThatGeneric.IsEquatableTo.Tests.cs Test suite for IsEquatableTo method covering success/failure cases and negated scenarios
Tests/aweXpect.Tests/ThatGeneric.IsNotEquatableTo.Tests.cs Test suite for IsNotEquatableTo method covering success/failure cases and negated scenarios
Tests/aweXpect.Api.Tests/Expected/aweXpect_netstandard2.0.txt Updated API surface for .NET Standard 2.0 target
Tests/aweXpect.Api.Tests/Expected/aweXpect_net8.0.txt Updated API surface for .NET 8.0 target

Comment thread Source/aweXpect/That/ThatGeneric.IsEquatableTo.cs
@vbreuss vbreuss force-pushed the topic/support-iequatable branch from b09a6ef to b3510cf Compare September 2, 2025 09:10
@vbreuss vbreuss enabled auto-merge (squash) September 2, 2025 09:12
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Sep 2, 2025

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 2, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.14.0, Ubuntu 24.04.3 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.413
[Host] : .NET 8.0.19 (8.0.1925.36514), X64 RyuJIT AVX2

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

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 205.8 ns 2.32 ns 2.05 ns 0.0300 - 504 B
Bool_FluentAssertions 248.7 ns 0.74 ns 0.66 ns 0.0567 - 952 B
Bool_TUnit 936.3 ns 5.13 ns 4.55 ns 0.1431 - 2408 B
Equivalency_aweXpect 280,416.7 ns 1,339.48 ns 1,187.41 ns 16.6016 0.4883 284972 B
Equivalency_FluentAssertions 2,303,721.1 ns 7,214.42 ns 6,748.37 ns 273.4375 46.8750 4584416 B
Equivalency_TUnit 670,062.8 ns 2,811.15 ns 2,629.55 ns 51.7578 2.9297 880545 B
Int_GreaterThan_aweXpect 237.2 ns 0.76 ns 0.67 ns 0.0486 - 816 B
Int_GreaterThan_FluentAssertions 245.0 ns 1.44 ns 1.35 ns 0.0730 - 1224 B
Int_GreaterThan_TUnit 1,228.9 ns 6.38 ns 5.66 ns 0.1774 - 2984 B
ItemsCount_AtLeast_aweXpect 493.0 ns 1.26 ns 1.05 ns 0.0868 - 1464 B
ItemsCount_AtLeast_FluentAssertions 488.5 ns 7.38 ns 6.90 ns 0.1192 - 2008 B
ItemsCount_AtLeast_TUnit 16,140.5 ns 105.34 ns 93.38 ns 1.6174 - 27480 B
String_aweXpect 387.8 ns 1.82 ns 1.70 ns 0.0691 - 1160 B
String_FluentAssertions 473.6 ns 4.71 ns 4.41 ns 0.1292 - 2168 B
String_TUnit 1,247.5 ns 3.83 ns 3.40 ns 0.1831 - 3072 B
StringArray_aweXpect 1,351.2 ns 12.08 ns 10.71 ns 0.1659 - 2776 B
StringArray_FluentAssertions 1,260.5 ns 24.71 ns 23.12 ns 0.2480 - 4152 B
StringArray_TUnit 3,370.7 ns 23.42 ns 20.76 ns 0.3128 - 5296 B
StringArrayInAnyOrder_aweXpect 1,590.3 ns 11.74 ns 10.98 ns 0.1755 - 2952 B
StringArrayInAnyOrder_FluentAssertions 153,545.1 ns 995.29 ns 930.99 ns 3.4180 - 63787 B
StringArrayInAnyOrder_TUnit 3,910.9 ns 14.58 ns 13.63 ns 0.3815 - 6488 B

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 2, 2025

Test Results

    4 files  ±0      4 suites  ±0   24s ⏱️ +5s
  955 tests ±0    954 ✅ ±0  1 💤 ±0  0 ❌ ±0 
2 751 runs  ±0  2 750 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit ab6f873. ± Comparison against base commit f6a6c87.

This pull request removes 54 and adds 54 tests. Note that renamed tests count towards both.
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message0fe6b47a-30bf-42bf-9570-b6d8ed3d2d22")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message8968b993-699e-4572-8909-059620f6d308")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message8c19b257-ece2-47d1-a8d4-20c8d9aa65ae")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message0be626dd-dc54-455d-9ed6-ca4f4afa2b4b")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message473c7755-cbff-40b1-b25e-1aad3e4c9dba")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messagea1acc8b8-2548-4070-a4fa-6619b6111f54")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore03bfbdeb-f4ca-4ee8-8105-5ba5b2868a14")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore23c94d59-5512-4b82-b502-96fb07c97b5f")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnorec62b43d2-7216-436a-a01b-3f50c549f3f0")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reason62853645-2614-45c1-935a-66ceb1d3e962")
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message27a596bb-c762-4cd6-98f5-3569530274bb")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message44bbd79f-41f9-4d83-be2d-295e6fa91444")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "messagee00aa8dc-9eec-40ef-b4d3-ed7c0cf18fc4")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message54b2fecb-c9a4-4aea-b07f-ed2868d57915")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message95757244-c70e-4f5a-86ba-91160bd7ed68")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messaged084fbc7-ae95-473c-823e-d827f4ef66ba")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore38e267a3-e019-4721-8f63-93e60e136c37")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore6486940a-8e60-4f69-8147-9e73ad2e5c3c")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnorece026fac-477b-491b-9737-7b8307a6e85e")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reason4b6290ad-e15b-4693-9fc4-102366bc8291")
…

@vbreuss vbreuss merged commit df92234 into main Sep 2, 2025
14 checks passed
@vbreuss vbreuss deleted the topic/support-iequatable branch September 2, 2025 09:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 2, 2025

This is addressed in release v2.22.0.

@github-actions github-actions Bot added the state: released The issue is released label Sep 2, 2025
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.

IsEqualTo does not use Equals from IEquatable<T>

2 participants