public void IEquatableHasPrecedenceOverEnumerableEquals() { var x = new EquatableWithEnumerableObject <int>(new[] { 1, 2, 3, 4, 5 }, 42); var y = new EnumerableObject <int>(new[] { 5, 4, 3, 2, 1 }, 42); var z = new EnumerableObject <int>(new[] { 1, 2, 3, 4, 5 }, 15); Assert.That(comparer.AreEqual(x, y, ref tolerance), Is.True); Assert.That(comparer.AreEqual(y, x, ref tolerance), Is.True); Assert.That(comparer.AreEqual(x, z, ref tolerance), Is.False); Assert.That(comparer.AreEqual(z, x, ref tolerance), Is.False); // TODO: Reinstate commented cases //Assert.That(y, Is.EqualTo(x)); //Assert.That(x, Is.EqualTo(y)); //Assert.That(z, Is.Not.EqualTo(x)); //Assert.That(x, Is.Not.EqualTo(z)); }
public void IEquatableIsIgnoredAndEnumerableEqualsUsedWithAsCollection() { comparer.CompareAsCollection = true; var x = new EquatableWithEnumerableObject <int>(new[] { 1, 2, 3, 4, 5 }, 42); var y = new EnumerableObject <int>(new[] { 5, 4, 3, 2, 1 }, 42); var z = new EnumerableObject <int>(new[] { 1, 2, 3, 4, 5 }, 15); Assert.That(comparer.AreEqual(x, y, ref tolerance), Is.False); Assert.That(comparer.AreEqual(y, x, ref tolerance), Is.False); Assert.That(comparer.AreEqual(x, z, ref tolerance), Is.True); Assert.That(comparer.AreEqual(z, x, ref tolerance), Is.True); //Assert.That(y, Is.Not.EqualTo(x).AsCollection); //Assert.That(x, Is.Not.EqualTo(y).AsCollection); Assert.That(z, Is.EqualTo(x).AsCollection); Assert.That(x, Is.EqualTo(z).AsCollection); }