Skip to content

Is.EqualTo with empty ValueTuple throws System.NotSupportedException "Specified Tolerance not supported for instances of type 'System.ValueTuple' and 'System.ValueTuple'" after updating to NUnit 4.2.2 #4807

@KrzysFR

Description

@KrzysFR

After updating from NUnit 4.1 to 4.2.2, I have the following error when comparing the value of a ValueTuple (empty tuple) with Is.EqualTo constraint:

System.NotSupportedException : Specified Tolerance not supported for instances of type 'System.ValueTuple' and 'System.ValueTuple'

The issue does NOT happen when comparing to a non-empty tuple, or with the Is.Not.EqualTo constraint.

Sample code:

[TestFixture]
public class ReproTest
{
	[Test]
	public void Test_ValueTuple_Equality()
	{
		Assert.Multiple(() =>
		{
			// 4.1: PASS, 4.2.2: **FAIL**
			Assert.That(ValueTuple.Create(), Is.EqualTo(ValueTuple.Create()), "() == ()"); // => throws NotSupportedException !

			// 4.1: PASS, 4.2.2: PASS
			Assert.That(ValueTuple.Create(123), Is.EqualTo(ValueTuple.Create(123)), "(123,) == (123,)");

			// 4.1: PASS, 4.2.2: PASS
			Assert.That(ValueTuple.Create(123), Is.Not.EqualTo(ValueTuple.Create()), "(123,) != ()");

			// 4.1: PASS, 4.2.2: PASS
			Assert.That(ValueTuple.Create(), Is.Not.EqualTo(ValueTuple.Create(123)), "() != (123,)");
		});
	}
}

Observed error in 4.2.2:

System.NotSupportedException : Specified Tolerance not supported for instances of type 'System.ValueTuple' and 'System.ValueTuple'
   at NUnit.Framework.Constraints.NUnitEqualityComparer.AreEqual(Object x, Object y, Tolerance& tolerance)
   at NUnit.Framework.Constraints.EqualConstraint.ApplyTo[TActual](TActual actual)
   at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression, NUnitString message, String actualExpression, String constraintExpression)
   at ReproTest.Test_ValueTuple_Equality()
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions