本文整理匯總了C#中System.Duration.EqualsEpsilon方法的典型用法代碼示例。如果您正苦於以下問題:C# Duration.EqualsEpsilon方法的具體用法?C# Duration.EqualsEpsilon怎麽用?C# Duration.EqualsEpsilon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Duration
的用法示例。
在下文中一共展示了Duration.EqualsEpsilon方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestEquality
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));
}