Esempio n. 1
0
        public virtual void TestArrayComparator()
        {
            IComparator <bool[]> ac = Comparators.GetArrayComparator();

            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { true, false, true }, new bool[] { true, false, true }) == 0);
            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { true, false, true }, new bool[] { true, false }) > 0);
            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { true, false, true }, new bool[] { true, false, true, false }) < 0);
            NUnit.Framework.Assert.IsTrue(ac.Compare(new bool[] { false, false, true }, new bool[] { true, false, true }) < 0);
        }
Esempio n. 2
0
        public virtual void TestNullSafeComparator()
        {
            IComparator <int> comp = Comparators.NullSafeNaturalComparator();

            NUnit.Framework.Assert.AreEqual(0, comp.Compare(null, null));
            NUnit.Framework.Assert.AreEqual(-1, comp.Compare(null, int.Parse(42)));
            NUnit.Framework.Assert.AreEqual(1, comp.Compare(int.Parse(42), null));
            NUnit.Framework.Assert.AreEqual(-1, comp.Compare(11, 18));
            NUnit.Framework.Assert.AreEqual(0, comp.Compare(11, 11));
        }
Esempio n. 3
0
        public virtual void TestListComparator()
        {
            IComparator <IList <string> > lc = Comparators.GetListComparator();

            string[] one   = new string[] { "hello", "foo" };
            string[] two   = new string[] { "hi", "foo" };
            string[] three = new string[] { "hi", "foo", "bar" };
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(one), Arrays.AsList(one)) == 0);
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(one), Arrays.AsList(two)) < 0);
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(one), Arrays.AsList(three)) < 0);
            NUnit.Framework.Assert.IsTrue(lc.Compare(Arrays.AsList(three), Arrays.AsList(two)) > 0);
        }