public void TestEquivalence() { Fingerprint fp1 = new Fingerprint(65); Fingerprint fp2 = new Fingerprint(65); Fingerprint fp3 = new Fingerprint(64); Fingerprint fp4 = new Fingerprint(66); // Reference first Assert.True(fp1.Equivalent(fp1)); Assert.True(fp2.Equivalent(fp2)); Assert.True(fp3.Equivalent(fp3)); Assert.True(fp4.Equivalent(fp4)); // Length second Assert.True(fp3.Equivalent(fp1)); Assert.False(fp1.Equivalent(fp3)); Assert.False(fp4.Equivalent(fp2)); Assert.True(fp2.Equivalent(fp4)); // Bits third Assert.True(fp1.Equivalent(fp2)); Assert.True(fp2.Equivalent(fp1)); fp1.Touch(32); Assert.False(fp1.Equivalent(fp2)); Assert.True(fp2.Equivalent(fp1)); fp2.Touch(32); Assert.True(fp1.Equivalent(fp2)); Assert.True(fp2.Equivalent(fp1)); fp2.Touch(31); Assert.True(fp1.Equivalent(fp2)); Assert.False(fp2.Equivalent(fp1)); fp4.Touch(31); fp4.Touch(32); fp4.Touch(33); Assert.True(fp2.Equivalent(fp4)); Assert.False(fp4.Equivalent(fp2)); }
/// <summary> /// Determines whether the specified Cell object is equivalent to this /// one based on the given fingerprint. /// </summary> public bool Equivalent(Cell other, Fingerprint fingerprint) { if (!other.IsKindOf(this)) { return false; } if (!fingerprint.Equivalent(other.fingerprint)) { return false; } return IsEquivalent(other, fingerprint); }