public void TestCompareTo()
        {
            Duration duration1 = new Duration(1, 0.0);
            Duration duration2 = new Duration(1, 0.0);
            Assert.IsTrue(duration1.CompareTo(duration2) == 0);
            Assert.IsTrue(duration2.CompareTo(duration1) == 0);
            Assert.IsTrue(duration1 >= duration2);
            Assert.IsTrue(duration2 <= duration1);
            Assert.IsTrue(duration1 <= duration2);
            Assert.IsTrue(duration2 >= duration1);

            duration2 = new Duration(2, 0.0);
            Assert.IsTrue(duration1.CompareTo(duration2) < 0);
            Assert.IsTrue(duration2.CompareTo(duration1) > 0);
            Assert.IsTrue(duration1 < duration2);
            Assert.IsTrue(duration2 > duration1);
            Assert.IsTrue(duration1 <= duration2);
            Assert.IsTrue(duration2 >= duration1);

            duration2 = new Duration(1, 1.0);
            Assert.IsTrue(duration1.CompareTo(duration2) < 0);
            Assert.IsTrue(duration2.CompareTo(duration1) > 0);
            Assert.IsTrue(duration1 < duration2);
            Assert.IsTrue(duration2 > duration1);
            Assert.IsTrue(duration1 <= duration2);
            Assert.IsTrue(duration2 >= duration1);
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 public void TestObjectCompareToNotDuration()
 {
     Duration duration1 = new Duration(1, 1.0);
     Assert.IsTrue(duration1.CompareTo(5) == 0);
 }
Beispiel #4
0
        public void TestObjectCompareTo()
        {
            Duration duration1 = new Duration(1, 1.0);
            Assert.IsTrue(duration1.CompareTo(null) > 0);

            object duration2 = new Duration(1, 1.0);
            Assert.IsTrue(duration1.CompareTo(duration2) == 0);
        }
Beispiel #5
0
 public void CompareToShouldThrowException()
 {
     var date = new Duration();
     date.CompareTo(null);
 }