本文整理汇总了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));
}