public void TestEquality() { Duration first = new Duration(5, 565.0); Duration second = new Duration(5, 565.0); Assert.AreEqual(first, second); Assert.IsTrue(first.Equals(second)); Assert.IsTrue(second.Equals(first)); Assert.IsTrue(first == second); Assert.IsTrue(second == first); Assert.IsFalse(first != second); Assert.IsFalse(second != first); Assert.AreEqual(0, first.CompareTo(second)); Assert.AreEqual(0, second.CompareTo(first)); first = new Duration(5, 0.00001); second = new Duration(4, 86399.99999); Assert.AreNotEqual(first, second); Assert.IsFalse(first.Equals(second)); Assert.IsFalse(second.Equals(first)); Assert.IsFalse(first == second); Assert.IsFalse(second == first); Assert.IsTrue(first != second); Assert.IsTrue(second != first); Assert.AreNotEqual(0, first.CompareTo(second)); Assert.AreNotEqual(0, second.CompareTo(first)); Assert.IsTrue(first.EqualsEpsilon(second, 1e-4)); Assert.IsTrue(second.EqualsEpsilon(first, 1e-4)); // Make sure a Duration compared with a non-Duration returns false Assert.IsFalse(first.Equals(5)); }