Skip to content

Is.Not.EqualTo does not work correctly with Using comparer #4964

Description

@igor-vyatkin

If we apply custom comparer with Using to Is.Not.EqualTo then Not is ignored and it starts to work as Is.EqualTo with Using.

Test below fails but should pass:

[Test]
public void UsesProvidedIComparerWithNot()
{
    var comparer = new ObjectComparer();
    Assert.Multiple(() =>
    {
        Assert.That(2 + 3, Is.Not.EqualTo(4).Using(comparer));
        Assert.That(comparer.WasCalled, "Comparer was not called");
    });
}

It produces the followong error:

Assert.That(2 + 3, Is.Not.EqualTo(4).Using(comparer))
  Expected: 4
  But was:  5

If just remove .Using(comparer) it starts to work as expected.

Tested with latest NUnit 4.3.2 and .NET 8.

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions