Ejemplo n.º 1
0
        public void CompareString()
        {
            string aaa = "aaa";
            string bbb = "aab";

            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(aaa, bbb));
            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(bbb, aaa));
            Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects(aaa, aaa));

            VmCompareCouple(aaa, bbb);

            char  c = 'c';
            short s = 7;

            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(bbb, c));
            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(c, bbb));
            Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects(c, c));

            VmCompareCouple(aaa, c);
            VmCompareCouple(bbb, c);

            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(aaa, s));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(s, bbb));

            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(c, s));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(s, c));

            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(c, aaa));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(bbb, c));

            VmCompareCouple(s, aaa);
            VmCompareCouple(s, c);
        }
Ejemplo n.º 2
0
 public void CompareEnums()
 {
     Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects(FileAccess.Read, FileAccess.Read));
     Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects(FileAccess.Read, "Read"));
     Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects("Read", FileAccess.Read));
     Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects("Reader", FileAccess.Read));
 }
Ejemplo n.º 3
0
        public void CompareTimeSpan()
        {
            TimeSpan longer  = new TimeSpan(15, 12, 37, 12);
            TimeSpan shorter = new TimeSpan(17, 56, 59);

            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(longer, shorter));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(shorter, longer));
            Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects(shorter, shorter));

            VmCompareCouple(shorter, longer);
        }
Ejemplo n.º 4
0
        public void CompareDateTime()
        {
            DateTime now  = DateTime.Now;
            DateTime next = now.AddSeconds(3);

            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(now, next));
            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(next, now));
            Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects(now, now));

            VmCompareCouple(now, next);
        }
Ejemplo n.º 5
0
        public void ComparePrimitive()
        {
            Assert.Equal(ObjectComparer.Equal, ObjectComparer.CompareObjects(Int, Int));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(Int, Double));
            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(Double, Int));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(Float, Double));
            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(Double, Float));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(Int, Float));
            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(Float, Int));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(ULong, Float));
            Assert.Equal(ObjectComparer.Greater, ObjectComparer.CompareObjects(Double, ULong));
            Assert.Equal(ObjectComparer.Smaller, ObjectComparer.CompareObjects(Int, ULong));

            VmCompareCouple(Int, Double);
            VmCompareCouple(Int, Float);
            VmCompareCouple(Int, ULong);
            VmCompareCouple(ULong, Float);
            VmCompareCouple(Float, Double);
            VmCompareCouple(ULong, Double);
        }