本文整理汇总了C#中DateInterval.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# DateInterval.GetHashCode方法的具体用法?C# DateInterval.GetHashCode怎么用?C# DateInterval.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateInterval
的用法示例。
在下文中一共展示了DateInterval.GetHashCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals_EqualValues
public void Equals_EqualValues()
{
LocalDate start = new LocalDate(2000, 1, 1);
LocalDate end = new LocalDate(2001, 6, 19);
var interval1 = new DateInterval(start, end, false);
var interval2 = new DateInterval(start, end, false);
Assert.AreEqual(interval1, interval2);
Assert.AreEqual(interval1.GetHashCode(), interval2.GetHashCode());
Assert.IsTrue(interval1 == interval2);
Assert.IsFalse(interval1 != interval2);
Assert.IsTrue(interval1.Equals(interval2)); // IEquatable implementation
}
示例2: Equals_DifferentCalendars
public void Equals_DifferentCalendars()
{
LocalDate start1 = new LocalDate(2000, 1, 1);
LocalDate end1 = new LocalDate(2001, 6, 19);
// This is a really, really similar calendar to ISO, but we do distinguish.
// TODO: Should we?
LocalDate start2 = start1.WithCalendar(CalendarSystem.Gregorian);
LocalDate end2 = end1.WithCalendar(CalendarSystem.Gregorian);
var interval1 = new DateInterval(start1, end1, false);
var interval2 = new DateInterval(start2, end2, false);
Assert.AreNotEqual(interval1, interval2);
Assert.AreNotEqual(interval1.GetHashCode(), interval2.GetHashCode());
Assert.IsFalse(interval1 == interval2);
Assert.IsTrue(interval1 != interval2);
Assert.IsFalse(interval1.Equals(interval2)); // IEquatable implementation
}
示例3: Equals_DifferentEnd
public void Equals_DifferentEnd()
{
LocalDate start = new LocalDate(2000, 1, 1);
LocalDate end1 = new LocalDate(2001, 6, 19);
LocalDate end2 = new LocalDate(2001, 6, 20);
var interval1 = new DateInterval(start, end1, false);
var interval2 = new DateInterval(start, end2, false);
Assert.AreNotEqual(interval1, interval2);
Assert.AreNotEqual(interval1.GetHashCode(), interval2.GetHashCode());
Assert.IsFalse(interval1 == interval2);
Assert.IsTrue(interval1 != interval2);
Assert.IsFalse(interval1.Equals(interval2)); // IEquatable implementation
}
示例4: Equals_SameRangeButNotEquivalent
public void Equals_SameRangeButNotEquivalent()
{
LocalDate start = new LocalDate(2000, 1, 1);
LocalDate end1 = new LocalDate(2001, 6, 19);
LocalDate end2 = new LocalDate(2001, 6, 20);
var interval1 = new DateInterval(start, end1, true);
var interval2 = new DateInterval(start, end2, false);
Assert.AreEqual(interval1.Length, interval2.Length);
Assert.AreNotEqual(interval1, interval2);
Assert.AreNotEqual(interval1.GetHashCode(), interval2.GetHashCode());
Assert.IsFalse(interval1 == interval2);
Assert.IsTrue(interval1 != interval2);
Assert.IsFalse(interval1.Equals(interval2)); // IEquatable implementation
}
示例5: Equals_DifferentCalendars
public void Equals_DifferentCalendars()
{
LocalDate start1 = new LocalDate(2000, 1, 1);
LocalDate end1 = new LocalDate(2001, 6, 19);
// This is a really, really similar calendar to ISO - the dates could differ by week of year,
// but that's all.
LocalDate start2 = start1.WithCalendar(CalendarSystem.GetGregorianCalendar(1));
LocalDate end2 = end1.WithCalendar(CalendarSystem.GetGregorianCalendar(1));
var interval1 = new DateInterval(start1, end1, false);
var interval2 = new DateInterval(start2, end2, false);
Assert.AreNotEqual(interval1, interval2);
Assert.AreNotEqual(interval1.GetHashCode(), interval2.GetHashCode());
Assert.IsFalse(interval1 == interval2);
Assert.IsTrue(interval1 != interval2);
Assert.IsFalse(interval1.Equals(interval2)); // IEquatable implementation
}