public void TestInverseComparer()
        {
            InverseComparer ic1 = new InverseComparer();
            InverseComparer ic2 = new InverseComparer();

            Assert.IsNotNull(ic1);
            Assert.AreEqual(ic1, ic2);
            Assert.AreEqual(ic1.ToString(), ic2.ToString());
            Assert.AreEqual(ic1.GetHashCode(), ic2.GetHashCode());

            InverseComparer ic3 = new InverseComparer(IdentityExtractor.Instance);

            Assert.AreNotEqual(ic1, ic3);
            Assert.IsNotNull(ic3.Comparer);
            Assert.AreEqual(ic3.Comparer, IdentityExtractor.Instance);

            Assert.AreEqual(ic1.Compare(null, null), 0);
            Assert.AreEqual(ic1.Compare(new object(), null), -1);
            Assert.AreEqual(ic1.Compare(null, new object()), 1);
            try
            {
                Assert.AreEqual(ic1.Compare(new object(), new object()), 0);
            }
            catch (Exception e)
            {
                Assert.IsInstanceOf(typeof(ArgumentException), e);
            }

            SafeComparer sc = new SafeComparer(IdentityExtractor.Instance);

            Assert.AreEqual(ic1.Compare(10, 100), 1);
            Assert.AreEqual(ic3.Compare(10, 100), -sc.Compare(10, 100));


            TestQueryCacheEntry entry1 = new TestQueryCacheEntry("k2", "aaa");
            TestQueryCacheEntry entry2 = new TestQueryCacheEntry("k1", "zzz");

            ic3 = new InverseComparer(IdentityExtractor.Instance);
            sc  = new SafeComparer(IdentityExtractor.Instance);

            Assert.AreEqual(ic3.CompareEntries(entry2, entry1), -1);
            Assert.AreEqual(ic3.CompareEntries(entry2, entry1), -sc.CompareEntries(entry2, entry1));

            InverseComparer ic4 = new InverseComparer(new KeyExtractor("Key"));

            Assert.AreEqual(ic4.Compare(entry1, entry2), -1);
        }
        public void TestSafeComparer()
        {
            SafeComparer sc1 = new SafeComparer();
            SafeComparer sc2 = new SafeComparer();

            Assert.IsNotNull(sc1);
            Assert.AreEqual(sc1, sc2);
            Assert.AreEqual(sc1.ToString(), sc2.ToString());
            Assert.AreEqual(sc1.GetHashCode(), sc2.GetHashCode());
            SafeComparer sc3 = new SafeComparer(IdentityExtractor.Instance);

            Assert.AreNotEqual(sc1, sc3);

            Assert.IsNotNull(sc3.Comparer);
            Assert.AreEqual(sc3.Comparer, IdentityExtractor.Instance);

            Assert.AreEqual(sc1.Compare(null, null), 0);
            Assert.AreEqual(sc1.Compare(new object(), null), 1);
            Assert.AreEqual(sc1.Compare(null, new object()), -1);
            try
            {
                Assert.AreEqual(sc1.Compare(new object(), new object()), 0);
            }
            catch (Exception e)
            {
                Assert.IsInstanceOf(typeof(ArgumentException), e);
            }

            Assert.AreEqual(sc1.Compare(10, 100), -1);
            Assert.AreEqual(sc3.Compare(10, 100), -1);


            TestQueryCacheEntry entry1 = new TestQueryCacheEntry("k2", "ana");
            TestQueryCacheEntry entry2 = new TestQueryCacheEntry("k1", "cana");

            sc3 = new SafeComparer(IdentityExtractor.Instance);
            Assert.AreEqual(sc3.CompareEntries(entry2, entry1), 1);
            IComparer c = new Comparer(CultureInfo.CurrentCulture);

            sc3 = new SafeComparer(c);
            Assert.AreEqual(sc3.CompareEntries(entry1, entry2), -1);
        }