当前位置: 首页>>代码示例>>C#>>正文


C# DateInterval.Equals方法代码示例

本文整理汇总了C#中DateInterval.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# DateInterval.Equals方法的具体用法?C# DateInterval.Equals怎么用?C# DateInterval.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateInterval的用法示例。


在下文中一共展示了DateInterval.Equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:12,代码来源:DateIntervalTest.cs

示例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
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:16,代码来源:DateIntervalTest.cs

示例3: Equals_DifferentToNull

 public void Equals_DifferentToNull()
 {
     LocalDate start = new LocalDate(2000, 1, 1);
     LocalDate end = new LocalDate(2001, 6, 19);
     var interval = new DateInterval(start, end, false);
     Assert.IsFalse(interval.Equals(null));
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:7,代码来源:DateIntervalTest.cs

示例4: Equals_DifferentToOtherType

 public void Equals_DifferentToOtherType()
 {
     LocalDate start = new LocalDate(2000, 1, 1);
     LocalDate end = new LocalDate(2001, 6, 19);
     var interval = new DateInterval(start, end, false);
     Assert.IsFalse(interval.Equals(Instant.FromUnixTimeTicks(0)));
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:7,代码来源:DateIntervalTest.cs

示例5: 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
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:13,代码来源:DateIntervalTest.cs

示例6: 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
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:15,代码来源:DateIntervalTest.cs

示例7: Equal_DateIntervalWithSameStartAndSameEndDifferentInclusions_ReturnsFalse

        public void Equal_DateIntervalWithSameStartAndSameEndDifferentInclusions_ReturnsFalse(
            bool minInclusive1, bool maxInclusive1,
            bool minInclusive2, bool maxInclusive2)
        {
            // Arrange
            var dateInterval1 = new DateInterval(now, inOneHour, minInclusive1, maxInclusive1);
            var dateInterval2 = new DateInterval(now, inOneHour, minInclusive2, maxInclusive2);

            // Act
            bool equals = dateInterval1.Equals(dateInterval2);

            // Assert
            Assert.False(equals);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:14,代码来源:DateIntervalTest.cs

示例8: Equal_DateIntervalWithSameStartAndSameEndDatesExcludeStartIncludeEnd_ReturnsTrue

        public void Equal_DateIntervalWithSameStartAndSameEndDatesExcludeStartIncludeEnd_ReturnsTrue()
        {
            // Arrange
            var dateInterval1 = new DateInterval(now, inOneHour, false, true);
            var dateInterval2 = new DateInterval(now, inOneHour, false, true);

            // Act
            bool value = dateInterval1.Equals(dateInterval2);

            // Assert
            Assert.True(value);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:12,代码来源:DateIntervalTest.cs

示例9: Equal_DateIntervalWithSameStartAndEndDates_ReturnTrue

        public void Equal_DateIntervalWithSameStartAndEndDates_ReturnTrue()
        {
            // Arrange
            var dateInterval1 = new DateInterval(now, inOneHour);
            var dateInterval2 = new DateInterval(now, inOneHour);

            // Act
            bool equals = dateInterval1.Equals(dateInterval2);

            // Assert
            Assert.True(equals);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:12,代码来源:DateIntervalTest.cs

示例10: Equal_DateIntervalWithSameStartAndDifferentEndDates_ReturnFalse

        public void Equal_DateIntervalWithSameStartAndDifferentEndDates_ReturnFalse()
        {
            // Arrange
            var dateInterval1 = new DateInterval(now, inOneHour);
            var dateInterval2 = new DateInterval(now, inThreeHours);

            // Act
            bool equals = dateInterval1.Equals(dateInterval2);

            // Assert
            Assert.False(equals);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:12,代码来源:DateIntervalTest.cs

示例11: 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
 }
开发者ID:jackthorley,项目名称:nodatime,代码行数:16,代码来源:DateIntervalTest.cs


注:本文中的DateInterval.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。