本文整理汇总了C#中DateRange.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# DateRange.Equals方法的具体用法?C# DateRange.Equals怎么用?C# DateRange.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateRange
的用法示例。
在下文中一共展示了DateRange.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals_ReturnsTrueForEquivelantStartAndEndDates
public void Equals_ReturnsTrueForEquivelantStartAndEndDates()
{
var start = DateTime.Today;
var end = DateTime.Now;
var target = new DateRange(start, end);
var other = new DateRange(start, end);
Assert.AreEqual(true, target.Equals(other));
}
示例2: Equals_ReturnsFalseForEquivelantStartAndDifferentEndDates
public void Equals_ReturnsFalseForEquivelantStartAndDifferentEndDates()
{
var start = DateTime.Today;
var end1 = start.AddMilliseconds(1);
var end2 = start.AddMilliseconds(2);
var target = new DateRange(start, end1);
var other = new DateRange(start, end2);
Assert.AreEqual(false, target.Equals(other));
}
示例3: Equals_ReturnsFalseForDifferentStartAndEquivelantEndDates
public void Equals_ReturnsFalseForDifferentStartAndEquivelantEndDates()
{
var start1 = DateTime.Today;
var start2 = DateTime.Today.AddMilliseconds(1);
var end = DateTime.Now;
var target = new DateRange(start1, end);
var other = new DateRange(start2, end);
Assert.AreEqual(false, target.Equals(other));
}
示例4: Equals_GivenVariousScenarios_ReturnsAsExpected
public void Equals_GivenVariousScenarios_ReturnsAsExpected()
{
DateRange first;
DateRange second;
first = new DateRange(null, null);
second = new DateRange(null, null);
Assert.IsTrue(first.Equals(second));
first = new DateRange(null, null);
second = new DateRange(DateTime.Now, null);
Assert.IsFalse(first.Equals(second));
DateTime dateTime = DateTime.Now;
first = new DateRange(dateTime, null);
second = new DateRange(dateTime, null);
Assert.IsTrue(first.Equals(second));
}
示例5: EqualsTest
public void EqualsTest()
{
DateRange target = new DateRange();
DateRange other = new DateRange();
bool expected = true;
bool actual = target.Equals(other);
Assert.AreEqual(expected, actual);
other = new DateRange(DateTime.Today, DateTime.Now);
actual = target.Equals(other);
expected = false;
Assert.AreEqual(expected, actual);
}
示例6: GetIntersectionTest
public void GetIntersectionTest()
{
var target = new DateRange(DateTime.Today.AddDays(-1), DateTime.Today);
var otherTarget = new DateRange(DateTime.Today, DateTime.Today.AddDays(1));
var expectedIntersection = new DateRange(DateTime.Today, DateTime.Today);
Assert.IsTrue(expectedIntersection.Equals(target.GetIntersection(otherTarget)));
}
示例7: GetWorkingDaysCount
public static int GetWorkingDaysCount(DateRange dateRange)
{
return !dateRange.Equals(DateRange.Empty)
? GetWorkingDaysCount(dateRange.StartDate.Value, dateRange.EndDate.Value)
: 0;
}
示例8: Equals_ReturnsTrueForInifiniteDateRanges
public void Equals_ReturnsTrueForInifiniteDateRanges()
{
var target = new DateRange();
var other = new DateRange();
Assert.AreEqual(true, target.Equals(other));
}
示例9: Equal_DateRangeWithDifferentStartAndSameEndDates_ReturnFalse
public void Equal_DateRangeWithDifferentStartAndSameEndDates_ReturnFalse()
{
// Arrange
DateTime t1 = DateTime.Now;
DateTime t2 = t1.AddHours(1);
DateTime t3 = t1.AddHours(3);
var dateRange1 = new DateRange(t1, t3);
var dateRange2 = new DateRange(t2, t3);
// Act
bool result = dateRange1.Equals(dateRange2);
// Assert
Assert.False(result);
}
示例10: Equal_DateRangeWithSameStartAndEndDates_ReturnTrue
public void Equal_DateRangeWithSameStartAndEndDates_ReturnTrue()
{
// Arrange
DateTime t1 = DateTime.Now;
DateTime t2 = t1.AddHours(1);
var dateRange1 = new DateRange(t1, t2);
var dateRange2 = new DateRange(t1, t2);
// Act
bool result = dateRange1.Equals( dateRange2 );
// Assert
Assert.True(result);
}