本文整理汇总了C#中ScheduleWidget.ScheduledEvents.Schedule.IsOccurring方法的典型用法代码示例。如果您正苦于以下问题:C# Schedule.IsOccurring方法的具体用法?C# Schedule.IsOccurring怎么用?C# Schedule.IsOccurring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScheduleWidget.ScheduledEvents.Schedule
的用法示例。
在下文中一共展示了Schedule.IsOccurring方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: YearTest2
public void YearTest2()
{
var aEvent = new Event()
{
ID = 1,
Title = "Event 2",
FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
Anniversary = new Anniversary()
{
Month = 9,
Day = 27
}
};
var schedule = new Schedule(aEvent);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 9, 27)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 9, 27)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 9, 27)));
var range = new DateRange()
{
StartDateTime = new DateTime(2012, 1, 1),
EndDateTime = new DateTime(2016, 12, 31)
};
var occurrences = schedule.Occurrences(range);
Assert.AreEqual(5, occurrences.Count());
Assert.AreEqual(new DateTime(2012, 9, 27), occurrences.First());
Assert.AreEqual(new DateTime(2016, 9, 27), occurrences.Last());
}
示例2: WeeklyEventOnEveryMonWedFriTest
public void WeeklyEventOnEveryMonWedFriTest()
{
var aEvent = new Event()
{
ID = 1,
Title = "Weekly on Monday, Wednesday, Friday",
Frequency = 64, // weekly on Monday, Wednesday, Friday
DaysOfWeek = 42, // every Mon, Wed and Fri
StartDateTime = new DateTime(2013, 8, 2)
};
var schedule = new Schedule(aEvent);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 2)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 3)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 4)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 5)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 6)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 7)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 8)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 9)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 10)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 11)));
}
示例3: RecurringScheduleIsOccurringTest1
public void RecurringScheduleIsOccurringTest1()
{
var aEvent = CreateRecurringEvent();
var schedule = new Schedule(aEvent);
Assert.IsNotNull(schedule);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2012, 10, 1)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 1, 18)));
}
示例4: EventOptionsIndependenceDayTest
public void EventOptionsIndependenceDayTest()
{
var holidays = GetHolidays();
var aEvent = CreateStreetCleaningEvent();
var schedule = new Schedule(aEvent, holidays);
Assert.IsNotNull(holidays);
Assert.IsNotNull(aEvent);
Assert.IsNotNull(schedule);
Assert.IsFalse(schedule.IsOccurring(new DateTime(2012, 7, 4)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2016, 7, 4)));
}
示例5: SimpleScheduleIsOccurringTest2
public void SimpleScheduleIsOccurringTest2()
{
var aEvent = CreateTodayEvent();
var schedule = new Schedule(aEvent);
Assert.IsNotNull(schedule);
Assert.IsFalse(schedule.IsOccurring(DateTime.Today.AddDays(1)));
}
示例6: EventOptionsLaborDayTest
public void EventOptionsLaborDayTest()
{
var holidays = GetHolidays();
var aEvent = CreateStreetCleaningEvent();
var schedule = new Schedule(aEvent, holidays);
Assert.IsNotNull(holidays);
Assert.IsNotNull(aEvent);
Assert.IsNotNull(schedule);
// Labor Day
Assert.IsFalse(schedule.IsOccurring(new DateTime(2012, 9, 3)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 9, 2)));
// Third Monday in Sep
Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 9, 15)));
}
示例7: AnniversaryTest2
public void AnniversaryTest2()
{
var anniversary = new Anniversary()
{
Day = 5,
Month = 6
};
var aEvent = new Event()
{
ID = 1,
Title = "Give Flowers to Wife",
Frequency = 16, // yearly
Anniversary = anniversary
};
var schedule = new Schedule(aEvent);
Assert.IsFalse(schedule.IsOccurring(new DateTime(2009, 6, 4)));
var range = new DateRange()
{
StartDateTime = new DateTime(2010, 1, 1),
EndDateTime = new DateTime(2020, 12, 31)
};
var occurrences = schedule.Occurrences(range).ToList();
Assert.IsTrue(occurrences.Count.Equals(11));
}
示例8: MonthTest1
public void MonthTest1()
{
var aEvent = new Event()
{
ID = 1,
Title = "Event 1",
FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
MonthlyIntervalOptions = MonthlyIntervalEnum.EveryWeek,
DaysOfWeekOptions = DayOfWeekEnum.Mon | DayOfWeekEnum.Fri
};
var range = new DateRange()
{
StartDateTime = new DateTime(2013, 1, 15),
EndDateTime = new DateTime(2013, 4, 30)
};
var occurringDate = new DateTime(2013, 1, 21);
var schedule = new Schedule(aEvent);
Assert.IsTrue(schedule.IsOccurring(occurringDate));
var previousOccurrence = schedule.PreviousOccurrence(occurringDate, range);
Assert.AreEqual(new DateTime(2013, 1, 18), previousOccurrence.Value);
var nextOccurrence = schedule.NextOccurrence(occurringDate, range);
Assert.AreEqual(new DateTime(2013, 1, 25), nextOccurrence.Value);
var occurrences = schedule.Occurrences(range);
Assert.AreEqual(30, occurrences.Count());
Assert.AreEqual(new DateTime(2013, 1, 18), occurrences.First());
Assert.AreEqual(new DateTime(2013, 4, 29), occurrences.Last());
}
示例9: SimpleScheduleIsOccurringTest1
public void SimpleScheduleIsOccurringTest1()
{
var aEvent = CreateTodayEvent();
var schedule = new Schedule(aEvent);
Assert.IsNotNull(schedule);
Assert.IsTrue(schedule.IsOccurring(DateTime.Today));
}
示例10: DailyEventTest1
public void DailyEventTest1()
{
var aEvent = new Event()
{
ID = 1,
Title = "Event 1",
Frequency = 1, // daily
MonthlyInterval = 0, // not applicable
DaysOfWeek = 127 // every day of week
};
var schedule = new Schedule(aEvent);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 2, 10)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 4, 29)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 11, 17)));
}
示例11: DailyEventTest3
public void DailyEventTest3()
{
var aEvent = new Event()
{
ID = 1,
Title = "Event 3",
FrequencyTypeOptions = FrequencyTypeEnum.Daily,
RepeatInterval = 4,
StartDateTime = new DateTime(2013, 1, 3)
};
var schedule = new Schedule(aEvent);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 1, 7)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 1, 12)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 2, 4)));
}
示例12: DailyEventTest2
public void DailyEventTest2()
{
var aEvent = new Event()
{
ID = 1,
Title = "Event 2",
RangeInYear = null,
Frequency = 1, // daily
MonthlyInterval = 0, // not applicable
DaysOfWeek = 16 // Thursday
};
var schedule = new Schedule(aEvent);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 2, 14)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 4, 25)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 11, 7)));
}
示例13: YearTest1
public void YearTest1()
{
var aEvent = new Event()
{
ID = 1,
Title = "Event 1",
FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
Anniversary = new Anniversary()
{
Month = 9,
Day = 27
}
};
var schedule = new Schedule(aEvent);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 9, 27)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 9, 27)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 9, 27)));
}
示例14: SimpleExcludedDayTest2
public void SimpleExcludedDayTest2()
{
// first Mon of Sep
var excludedDay = new DateTime(2012, 9, 3);
var aEvent = CreateRecurringEvent();
var excludedDates = new List<DateTime>()
{
excludedDay
};
var schedule = new Schedule(aEvent, excludedDates);
Assert.IsNotNull(schedule);
Assert.IsFalse(schedule.IsOccurring(excludedDay));
}
示例15: FineGrainedRangeInYearTest
public void FineGrainedRangeInYearTest()
{
var holidays = GetHolidays();
var aEvent = CreateFineGrainedStreetCleaningEvent();
var schedule = new Schedule(aEvent, holidays);
Assert.IsNotNull(holidays);
Assert.IsNotNull(aEvent);
Assert.IsNotNull(schedule);
Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 6, 20)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 5, 16)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 6, 6)));
Assert.IsTrue(schedule.IsOccurring(new DateTime(2018, 10, 15)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 11, 5)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 1, 1)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 2, 5)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 3, 19)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 11, 1)));
Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 12, 1)));
}