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); }
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); }