/// <summary>
 /// Determine if two comparers are equal.
 /// </summary>
 /// <param name="o">
 /// The other comparer.
 /// </param>
 /// <returns>
 /// <b>true</b> if the passed object is equal to this.
 /// </returns>
 public override bool Equals(object o)
 {
     if (o is EntryComparer)
     {
         EntryComparer target = (EntryComparer)o;
         return(base.Equals(o) && m_style == target.m_style);
     }
     else
     {
         return(false);
     }
 }
        public void TestEntryComparer()
        {
            EntryComparer ec1 = new EntryComparer();

            Assert.IsNotNull(ec1);
            Assert.IsNull(ec1.Comparer);
            Assert.AreEqual(ec1.ComparisonStyle, ComparisonStyle.Auto);

            EntryComparer ec2 = new EntryComparer(IdentityExtractor.Instance);
            EntryComparer ec3 = new EntryComparer(IdentityExtractor.Instance, ComparisonStyle.Auto);

            Assert.IsNotNull(ec2);
            Assert.AreEqual(ec2, ec3);
            Assert.AreEqual(ec2.ToString(), ec3.ToString());
            Assert.AreEqual(ec2.GetHashCode(), ec3.GetHashCode());
            Assert.IsTrue(ec2.CompareValue);
            Assert.IsFalse(ec2.CompareEntry);

            CacheEntry entry1 = new CacheEntry("k1", 100);
            CacheEntry entry2 = new CacheEntry("k2", 1);

            ec2 = new EntryComparer(new KeyExtractor(IdentityExtractor.Instance), ComparisonStyle.Auto);
            Assert.IsTrue(ec2.CompareKey);
            Assert.AreEqual(ec2.Compare(entry1, entry2), -1);

            ec2 = new EntryComparer(IdentityExtractor.Instance, ComparisonStyle.Auto);
            Assert.IsTrue(ec2.CompareValue);
            Assert.AreEqual(ec2.Compare(entry1, entry2), 1);

            ec2 = new EntryComparer(IdentityExtractor.Instance, ComparisonStyle.Entry);
            Assert.IsTrue(ec2.CompareEntry);
            Assert.AreEqual(ec2.Compare(entry1, entry2), 1);

            TestQueryCacheEntry qentry1 = new TestQueryCacheEntry("k1", 100);
            TestQueryCacheEntry qentry2 = new TestQueryCacheEntry("k2", 1);

            Assert.AreEqual(ec2.Compare(qentry1, qentry2), 1);
        }