本文整理汇总了C#中DateRange.Includes方法的典型用法代码示例。如果您正苦于以下问题:C# DateRange.Includes方法的具体用法?C# DateRange.Includes怎么用?C# DateRange.Includes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateRange
的用法示例。
在下文中一共展示了DateRange.Includes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Includes_DateIsBetween_ReturnsTrue
public void Includes_DateIsBetween_ReturnsTrue()
{
DateTime effectiveDate = new DateTime ( 2000, 1, 1 );
DateTime expirationDate = new DateTime ( 2000, 2, 1 );
DateTime otherDate = new DateTime ( 2000, 1, 15 );
DateRange dateRange = new DateRange ( effectiveDate, expirationDate );
Assert.IsTrue ( dateRange.Includes ( otherDate ) );
}
示例2: DetectsADateTimeNotInRange_ReturnsFalse_NoException
public void DetectsADateTimeNotInRange_ReturnsFalse_NoException()
{
DateTime testDate = DateTime.Now;
DateTime startDate = testDate.AddMonths(months: 1);
DateTime endDate = testDate.AddMonths(months: 2);
DateRange range = new DateRange(startDate, endDate);
var expected = false;
var actual = range.Includes(testDate);
Assert.IsTrue(actual == expected, message: "The date is not in the defined range, should have returned false");
}
示例3: DetectsARangeStartDateIsNotContainedWithinAnotherRange_ReturnsFalse_NoException
public void DetectsARangeStartDateIsNotContainedWithinAnotherRange_ReturnsFalse_NoException()
{
DateTime startDate1 = DateTime.Now;
DateTime endDate1 = DateTime.Now.AddMonths(months: 1);
DateTime startDate2 = DateTime.Now.AddDays(value: -7);
DateTime endDate2 = DateTime.Now.AddDays(value: 2);
DateRange range1 = new DateRange(startDate1, endDate1);
DateRange range2 = new DateRange(startDate2, endDate2);
var expected = false;
var actual = range1.Includes(range2);
Assert.IsTrue(actual == expected, message: "The range Start Date is not contained in the defined range, should have returned false");
}
示例4: Includes_ExpirationIsNull_ReturnsTrue
public void Includes_ExpirationIsNull_ReturnsTrue()
{
DateTime effectiveDate = new DateTime ( 2000, 1, 1 );
DateTime? expirationDate = null;
DateTime otherDate = new DateTime ( 2000, 1, 15 );
DateRange dateRange = new DateRange ( effectiveDate, expirationDate );
Assert.IsTrue ( dateRange.Includes ( otherDate ) );
}
示例5: ComparisonTest
public void ComparisonTest()
{
DateRange sd = new DateRange(d1, d1);
Assert.IsTrue(sd.Includes(d1.Value.AddHours(12)));
Assert.IsFalse(sd.Includes(d2.Value));
}
示例6: DateRangeDefaultConstructorTest
public void DateRangeDefaultConstructorTest()
{
DateRange target = new DateRange(); // Defaults to infinite range.
Assert.IsTrue(target.Includes(DateTime.MinValue));
Assert.IsTrue(target.Includes(DateTime.MaxValue));
}
示例7: Includes_IsTrueForStartDate
public void Includes_IsTrueForStartDate()
{
var target = new DateRange(DateTime.Today, DateTime.Now);
Assert.IsTrue(target.Includes(DateTime.Today));
}
示例8: ConstructorDefault_ConstructsInfiniteDateRange
public void ConstructorDefault_ConstructsInfiniteDateRange()
{
var target = new DateRange(); // Defaults to infinite range.
Assert.IsTrue(target.Includes(DateTime.MinValue));
Assert.IsTrue(target.Includes(DateTime.MaxValue));
}
示例9: Includes_IsTrueForEndDate
public void Includes_IsTrueForEndDate()
{
var now = DateTime.Now;
var target = new DateRange(DateTime.Today, now);
Assert.IsTrue(target.Includes(now));
}
示例10: Includes_IsTrueForDateBetweenStartAndEndDates
public void Includes_IsTrueForDateBetweenStartAndEndDates()
{
var target = new DateRange(DateTime.Today, DateTime.Today.AddDays(1));
Assert.IsTrue(target.Includes(DateTime.Today.AddHours(12)));
}
示例11: Includes_IsFalseForDateBeforeEndDate
public void Includes_IsFalseForDateBeforeEndDate()
{
var target = new DateRange(DateTime.Today, DateTime.Now);
Assert.IsFalse(target.Includes(DateTime.Today.AddMilliseconds(-1)));
}
示例12: Includes_IsFalseForDateAfterEndDate
public void Includes_IsFalseForDateAfterEndDate()
{
var now = DateTime.Now;
var target = new DateRange(DateTime.Today, now);
Assert.IsFalse(target.Includes(now.AddMilliseconds(1)));
}
示例13: Includes_IsAlwaysTrueForInfiniteRange
public void Includes_IsAlwaysTrueForInfiniteRange()
{
var target = new DateRange();
Assert.IsTrue(target.Includes(DateTime.Today));
Assert.IsTrue(target.Includes(DateTime.MinValue));
Assert.IsTrue(target.Includes(DateTime.MaxValue));
}