tpierrain/NFluent

IsEquivalentTo and ContainsExactly unexpected behaviour

KN4CK3R opened this issue · 2 comments

IsEquivalentTo and ContainsExactly have different behaviour but should not.

Expected Behavior

IsEquivalentTo(params object[]) and ContainsExactly(params object[]) should behave similiar.

Current Behavior

Check.That(new byte[] { 0, 1 }).IsEquivalentTo(0, 1); // Fail
// uses
ICheckLink<ICheck<IEnumerable>> IsEquivalentTo(this ICheck<IEnumerable> context, params object[] expectedValues)

Check.That(new byte[] { 0, 1 }).ContainsExactly(0, 1); // OK
// uses
ICheckLink<ICheck<IEnumerable>> ContainsExactly(this ICheck<IEnumerable> check, params object[] otherEnumerable)

Both use the params object[] overload but only IsEquivalentTo fails. The error message doesn't help and shows no error:

The checked enumerable does contain [1] whereas it should not.
The checked enumerable:
	{0, 1} (2 items)
The expected value(s):
	{0, 1} (2 items)'

Possible Solution

Let IsEquivalentTo pass or let ContainsExactly fail.

Code that reproduce the issue

Check.That(new byte[] { 0, 1 }).IsEquivalentTo(0, 1); // Fail
Check.That(new byte[] { 0, 1 }).IsEquivalentTo((byte)0, (byte)1); // OK
Check.That(new byte[] { 0, 1 }).ContainsExactly(0, 1); // OK
Check.That(new byte[] { 0, 1 }).ContainsExactly((byte)0, (byte)1); // OK

Your Environment

  • Version used: 2.6
  • Framework version: Core 3.1

May be related to #292.

Fixed in upcoming V 2.7 (see issue #307)

fixed in V 2.7.0