Skip to content

Conversation

Copy link

Copilot AI commented Nov 5, 2025

Pull Request Description

This PR introduces a new CheckEquality method to the IEqualizer interface, providing a boolean-based alternative to the existing exception-based AssertEquality and AssertInequality methods. This addresses use cases where a simple true/false result is preferred over exception-based flow control.

Motivation and Context

The IEqualizer interface previously only exposed AssertEquality and AssertInequality methods, which throw exceptions on assertion failure. However, there are common scenarios where developers need to check equality without the overhead of exception handling. The new CheckEquality method fills this gap by returning a boolean value (true if equal, false if not equal) without throwing exceptions.

Changes Made

  • IEqualizer interface: Added CheckEquality(object? expected, object? actual) method signature with XML documentation
  • Equalizer implementation: Implemented by delegating to the existing Equalize() internal method and returning the IsSuccessful property
  • Test refactoring: Refactored existing tests to use helper methods (AssertEquality and AssertInequality) that internally validate both the new CheckEquality method and the original assertion methods, ensuring comprehensive coverage without adding redundant test cases

Usage Example

var equalizer = new Equalizer();

// Before: exception-based flow
try 
{
    equalizer.AssertEquality(expected, actual);
    // continue if equal
} 
catch (InvalidAssertException) 
{
    // handle inequality
}

// After: boolean-based flow
if (equalizer.CheckEquality(expected, actual)) 
{
    // continue if equal
} 
else 
{
    // handle inequality
}

The implementation reuses existing equalization logic without duplicating any comparison behavior. All existing tests now also validate that CheckEquality returns the correct boolean value, providing thorough test coverage.

Fixes #62

Checklist

  • I have tested these changes thoroughly.
  • I have added/updated relevant documentation.
  • My code follows the project's coding guidelines.
  • I have performed a self-review of my changes.
  • My changes are backwards compatible.
Original prompt

This section details on the original issue you should resolve

<issue_title>Introduce the CheckEquality method</issue_title>
<issue_description>Describe your idea
Currently, the IEqualizer interface exposes only AssertEquality and AssertInequality methods. However, there are use cases in which we need the result as a boolean. I suggest we implement a new method - CheckEquality that will not throw exceptions for incorrect assertion, but will return true/false accordingly.

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: TonyTroeff <33567383+TonyTroeff@users.noreply.github.com>
Copilot AI changed the title [WIP] Introduce CheckEquality method to IEqualizer interface Add CheckEquality method to IEqualizer for boolean-based equality checks Nov 5, 2025
Copilot AI requested a review from TonyTroeff November 5, 2025 14:58
Copy link
Member

@TonyTroeff TonyTroeff left a comment

Choose a reason for hiding this comment

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

The changes look great. I added two minor suggestions.

@TonyTroeff TonyTroeff marked this pull request as ready for review November 8, 2025 07:12
Copy link
Member

@TonyTroeff TonyTroeff left a comment

Choose a reason for hiding this comment

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

The changes look great. I added two minor suggestions.

Co-authored-by: TonyTroeff <33567383+TonyTroeff@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 8, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@TonyTroeff TonyTroeff added enhancement A non-essential complement to a feature or a task task A simple unit of work used to move the features forward labels Nov 8, 2025
@TonyTroeff TonyTroeff added this to the 1.0.3 milestone Nov 8, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 8, 2025

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

Labels

enhancement A non-essential complement to a feature or a task task A simple unit of work used to move the features forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce the CheckEquality method

2 participants