Example #1
0
        public void TestComparisons()
        {
            GregorianDate date     = new GregorianDate(2001, 1, 1, 6, 3, 14);
            GregorianDate sameDate = new GregorianDate(2001, 1, 1, 6, 3, 14);

            GregorianDate laterTime = new GregorianDate(2001, 1, 1, 6, 5, 26);
            GregorianDate laterDay  = new GregorianDate(2001, 2, 2, 6, 3, 14);

            Assert.IsTrue(date == sameDate);
            Assert.IsTrue(sameDate == date);

            Assert.IsTrue(date != laterTime);

            Assert.IsTrue(date >= sameDate);
            Assert.IsTrue(date <= sameDate);

            Assert.IsTrue(date.CompareTo(sameDate) == 0);
            Assert.IsTrue(date.CompareTo(laterDay) < 0);

            Assert.IsTrue(sameDate < laterTime);
            Assert.IsTrue(sameDate <= laterTime);

            Assert.IsTrue(laterTime > sameDate);
            Assert.IsTrue(laterTime >= sameDate);

            object dateAsObject = new GregorianDate(2001, 1, 1, 6, 3, 15);

            Assert.AreNotEqual(date, dateAsObject);
        }
Example #2
0
        public void TestEquality()
        {
            GregorianDate first  = new GregorianDate(2000, 1, 1, 5, 1, 1);
            GregorianDate second = new GregorianDate(2000, 1, 1, 5, 1, 1);

            Assert.AreEqual(first, second);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));
            Assert.AreEqual(0, first.CompareTo(second));
            Assert.AreEqual(0, second.CompareTo(first));

            second = new GregorianDate(2000, 1, 1, 6, 1, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            second = new GregorianDate(2000, 2, 1, 5, 1, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            Assert.AreNotEqual(first, 5);
        }
Example #3
0
        public void TestEqualityInTimePortion()
        {
            GregorianDate first  = new GregorianDate(1999, 10, 10, 5, 1, 1);
            GregorianDate second = new GregorianDate(1999, 10, 10, 5, 1, 1);

            Assert.AreEqual(first, second);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));
            Assert.AreEqual(0, first.CompareTo(second));
            Assert.AreEqual(0, second.CompareTo(first));

            second = new GregorianDate(1999, 10, 10, 6, 1, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            second = new GregorianDate(1999, 10, 10, 5, 2, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            second = new GregorianDate(1999, 10, 10, 5, 1, 2);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            Assert.AreNotEqual(first, 5);
        }
Example #4
0
        public void TestCompareTimePortionObject()
        {
            GregorianDate gd1 = new GregorianDate(1999, 10, 10, 6, 3, 14);
            object        gd4 = new GregorianDate(1999, 10, 10, 4, 2, 21);

            Assert.IsTrue(gd1.CompareTo(null) > 0);
            Assert.IsTrue(gd1.CompareTo(gd4) > 0);
        }
Example #5
0
        public void TestCompareToObject()
        {
            GregorianDate date         = new GregorianDate(2001, 1, 1, 6, 3, 14);
            object        dateAsObject = new GregorianDate(2001, 1, 1, 6, 3, 15);

            Assert.IsTrue(date.CompareTo(null) > 0);
            Assert.IsTrue(date.CompareTo(dateAsObject) < 0);
        }
Example #6
0
        public void CompareToWithWrongTypeThrows()
        {
            GregorianDate gd = new GregorianDate(2001, 1, 1, 6, 3, 14);

            Assert.Throws <ArgumentException>(() =>
            {
                int unused = gd.CompareTo(5);
            });
        }
Example #7
0
        public void TestComparisonsOfTimePortion()
        {
            GregorianDate gd1 = new GregorianDate(1999, 10, 10, 6, 3, 14);
            GregorianDate gd2 = new GregorianDate(1999, 10, 10, 6, 3, 14);
            GregorianDate gd3 = new GregorianDate(1999, 10, 10, 6, 5, 26);
            object        gd4 = new GregorianDate(1999, 10, 10, 4, 2, 21);

            Assert.IsTrue(gd1 == gd2);
            Assert.IsTrue(gd2 == gd1);
            Assert.IsTrue(gd1 != gd3);
            Assert.IsTrue(gd1 >= gd2);
            Assert.IsTrue(gd1 <= gd2);
            Assert.IsTrue(gd1.CompareTo(gd2) == 0);
            Assert.IsTrue(gd2 < gd3);
            Assert.IsTrue(gd2 <= gd3);
            Assert.IsTrue(gd3 > gd2);
            Assert.IsTrue(gd3 >= gd2);
            Assert.AreNotEqual(gd1, gd4);
        }
Example #8
0
        public void CompareToWithWrongTypeThrows()
        {
            GregorianDate gd = new GregorianDate(2001, 1, 1, 6, 3, 14);

            gd.CompareTo(5);
        }
Example #9
0
        public void TestEquality()
        {
            GregorianDate first = new GregorianDate(2000, 1, 1, 5, 1, 1);
            GregorianDate second = new GregorianDate(2000, 1, 1, 5, 1, 1);
            Assert.AreEqual(first, second);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));
            Assert.AreEqual(0, first.CompareTo(second));
            Assert.AreEqual(0, second.CompareTo(first));

            second = new GregorianDate(2000, 1, 1, 6, 1, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            second = new GregorianDate(2000, 2, 1, 5, 1, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            Assert.AreNotEqual(first, 5);
        }
Example #10
0
 public void CompareToWithWrongTypeThrows()
 {
     GregorianDate gd = new GregorianDate(2001, 1, 1, 6, 3, 14);
     gd.CompareTo(5);
 }
Example #11
0
        public void TestCompareTimePortionObject()
        {
            GregorianDate gd1 = new GregorianDate(1999, 10, 10, 6, 3, 14);
            object gd4 = new GregorianDate(1999, 10, 10, 4, 2, 21);

            Assert.IsTrue(gd1.CompareTo(null) > 0);
            Assert.IsTrue(gd1.CompareTo(gd4) > 0);
        }
Example #12
0
        public void TestComparisonsOfTimePortion()
        {
            GregorianDate gd1 = new GregorianDate(1999, 10, 10, 6, 3, 14);
            GregorianDate gd2 = new GregorianDate(1999, 10, 10, 6, 3, 14);
            GregorianDate gd3 = new GregorianDate(1999, 10, 10, 6, 5, 26);
            object gd4 = new GregorianDate(1999, 10, 10, 4, 2, 21);

            Assert.IsTrue(gd1 == gd2);
            Assert.IsTrue(gd2 == gd1);
            Assert.IsTrue(gd1 != gd3);
            Assert.IsTrue(gd1 >= gd2);
            Assert.IsTrue(gd1 <= gd2);
            Assert.IsTrue(gd1.CompareTo(gd2) == 0);
            Assert.IsTrue(gd2 < gd3);
            Assert.IsTrue(gd2 <= gd3);
            Assert.IsTrue(gd3 > gd2);
            Assert.IsTrue(gd3 >= gd2);
            Assert.AreNotEqual(gd1, gd4);
        }
Example #13
0
        public void TestCompareToObject()
        {
            GregorianDate date = new GregorianDate(2001, 1, 1, 6, 3, 14);
            object dateAsObject = new GregorianDate(2001, 1, 1, 6, 3, 15);

            Assert.IsTrue(date.CompareTo(null) > 0);
            Assert.IsTrue(date.CompareTo(dateAsObject) < 0);
        }
Example #14
0
        public void TestComparisons()
        {
            GregorianDate date = new GregorianDate(2001, 1, 1, 6, 3, 14);
            GregorianDate sameDate = new GregorianDate(2001, 1, 1, 6, 3, 14);

            GregorianDate laterTime = new GregorianDate(2001, 1, 1, 6, 5, 26);
            GregorianDate laterDay = new GregorianDate(2001, 2, 2, 6, 3, 14);

            Assert.IsTrue(date == sameDate);
            Assert.IsTrue(sameDate == date);

            Assert.IsTrue(date != laterTime);

            Assert.IsTrue(date >= sameDate);
            Assert.IsTrue(date <= sameDate);

            Assert.IsTrue(date.CompareTo(sameDate) == 0);
            Assert.IsTrue(date.CompareTo(laterDay) < 0);

            Assert.IsTrue(sameDate < laterTime);
            Assert.IsTrue(sameDate <= laterTime);

            Assert.IsTrue(laterTime > sameDate);
            Assert.IsTrue(laterTime >= sameDate);

            object dateAsObject = new GregorianDate(2001, 1, 1, 6, 3, 15);
            Assert.AreNotEqual(date, dateAsObject);
        }
Example #15
0
        public void TestEqualityInTimePortion()
        {
            GregorianDate first = new GregorianDate(1999, 10, 10, 5, 1, 1);
            GregorianDate second = new GregorianDate(1999, 10, 10, 5, 1, 1);
            Assert.AreEqual(first, second);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));
            Assert.AreEqual(0, first.CompareTo(second));
            Assert.AreEqual(0, second.CompareTo(first));

            second = new GregorianDate(1999, 10, 10, 6, 1, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            second = new GregorianDate(1999, 10, 10, 5, 2, 1);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            second = new GregorianDate(1999, 10, 10, 5, 1, 2);
            Assert.AreNotEqual(first, second);
            Assert.IsFalse(first.Equals(second));
            Assert.IsFalse(second.Equals(first));
            Assert.AreNotEqual(0, first.CompareTo(second));
            Assert.AreNotEqual(0, second.CompareTo(first));

            Assert.AreNotEqual(first, 5);
        }