public void AddWeeklyEventEmptyEventDupThrows() { const string dupEvent = "duplicate"; CalendarDateTime.AddMonthlyDateEvent(dupEvent, true, 1); Assert.Throws <ArgumentException>(() => CalendarDateTime.AddMonthlyDateEvent(dupEvent, true, 1)); }
public void Remove() { const string monthlyKey = "monthlyKey"; const string weekKey = "WeekKey"; const string yearlyKey = "YearlyKey"; const string dateKey = "dateKey"; CalendarDateTime.ClearCalendar(); CalendarDateTime.AddYearlyDateEvent(yearlyKey, false, 1, 2, false, false); CalendarDateTime.AddMonthlyDateEvent(monthlyKey, true, 12); CalendarDateTime.AddWeeklyInMonthEvent(weekKey, false, DayOfWeek.Friday); CalendarDateTime.AddDateEvent(dateKey, false, DateTime.Now); Assert.False(CalendarDateTime.RemoveEvent("nothingRemoved")); Assert.True(CalendarDateTime.CountEvents == 4); Assert.True(CalendarDateTime.RemoveEvent(weekKey)); Assert.True(CalendarDateTime.CountEvents == 3); Assert.True(CalendarDateTime.RemoveEvent(dateKey)); Assert.True(CalendarDateTime.CountEvents == 2); Assert.True(CalendarDateTime.RemoveEvent(yearlyKey)); Assert.True(CalendarDateTime.CountEvents == 1); Assert.False(CalendarDateTime.RemoveEvent("notHere")); Assert.True(CalendarDateTime.CountEvents == 1); Assert.True(CalendarDateTime.RemoveEvent(monthlyKey)); Assert.True(CalendarDateTime.CountEvents == 0); }
public void AddMonthlyDayEventYearRange() { CalendarDateTime.ClearCalendar(); var event1Name = "Workday1"; const bool event1OffDay = false; var event1Day = 12; var firstValidDate = _startTestDate.AddYears(5); var lastValidDate = _endTestDate.AddYears(-5); Assert.Equal(0, CalendarDateTime.CountEvents); CalendarDateTime.AddMonthlyDateEvent(event1Name, event1OffDay, event1Day, firstValidDate, lastValidDate); Assert.Equal(1, CalendarDateTime.CountMonthlyEvents); Assert.Equal(1, CalendarDateTime.CountEvents); for (var currentDate = _startTestDate; currentDate <= _endTestDate; currentDate = currentDate.AddDays(1)) { Assert.Equal(currentDate.IsDayOff(), event1OffDay); Assert.Equal(currentDate.IsWorkDay(), !event1OffDay); var expected = new List <string>(); if (currentDate.IsBetweenEqual(firstValidDate, lastValidDate) && currentDate.Day == event1Day) { expected.Add(event1Name); } var actual = currentDate.EventsOnDate(true, true); Assert.Equal(expected, actual); } }
public void AddMonthlyDayEventThrowsInvalidDay() { CalendarDateTime.ClearCalendar(); Assert.Throws <ArgumentOutOfRangeException>(() => CalendarDateTime.AddMonthlyDateEvent("alpha", false, 0)); CalendarDateTime.AddMonthlyDateEvent("beta", true, 1); CalendarDateTime.AddMonthlyDateEvent("delta", true, 31); Assert.Throws <ArgumentOutOfRangeException>(() => CalendarDateTime.AddMonthlyDateEvent("gamma", false, 32)); }
public void ClearCalendar() { CalendarDateTime.ClearCalendar(); Assert.Equal(0, CalendarDateTime.CountEvents); CalendarDateTime.AddYearlyDateEvent("yearlyKey", false, 1, 2, false, false); CalendarDateTime.AddMonthlyDateEvent("monthlyKey", true, 12); CalendarDateTime.AddWeeklyInMonthEvent("weekKey", false, DayOfWeek.Friday); CalendarDateTime.AddDateEvent("dateKey", false, DateTime.Now); Assert.True(CalendarDateTime.CountEvents == 4); CalendarDateTime.ClearCalendar(); Assert.True(CalendarDateTime.CountEvents == 0); }
public void KeysMonthlyEvents() { const string m1 = "m1"; const string m2 = "m2"; var mSet = new List <string> { m1, m2 }; CalendarDateTime.ClearCalendar(); CalendarDateTime.AddMonthlyDateEvent(m1, true, 12); CalendarDateTime.AddMonthlyDateEvent(m2, true, 12); Assert.Equal(mSet, CalendarDateTime.KeysEvents.ToList()); Assert.Equal(mSet, CalendarDateTime.KeysMonthlyEvents.ToList()); }
public void CountCalendar() { CalendarDateTime.ClearCalendar(); CalendarDateTime.AddYearlyDateEvent("yearlyKey", false, 1, 2, false, false); CalendarDateTime.AddMonthlyDateEvent("month", true, 5); CalendarDateTime.AddWeeklyInMonthEvent("weekKey", false, DayOfWeek.Friday); CalendarDateTime.AddDateEvent("datedKey", false, DateTime.Now); var expected = 4; var actual = CalendarDateTime.CountEvents; Assert.Equal(expected, actual); CalendarDateTime.ClearCalendar(); Assert.Equal(0, CalendarDateTime.CountEvents); }
public void ClearMonthly() { CalendarDateTime.ClearCalendar(); Assert.Equal(0, CalendarDateTime.CountMonthlyEvents); Assert.Equal(0, CalendarDateTime.CountEvents); CalendarDateTime.AddMonthlyDateEvent("delta", false, 4); Assert.Equal(1, CalendarDateTime.CountMonthlyEvents); Assert.Equal(1, CalendarDateTime.CountEvents); CalendarDateTime.AddMonthlyDateEvent("force", false, 4); Assert.Equal(2, CalendarDateTime.CountMonthlyEvents); Assert.Equal(2, CalendarDateTime.CountEvents); CalendarDateTime.ClearCalendar(); Assert.Equal(0, CalendarDateTime.CountMonthlyEvents); Assert.Equal(0, CalendarDateTime.CountEvents); }
public void EventDatesBetweenMonthlyDateEvents() { var testDayName = "testDaDate"; const int testDay = 12; var expected = new List <DateTime>(); var start = new DateTime(_startTestDate.Year, _startTestDate.Month, testDay); for (var date = start; date <= _endTestDate; date = date.AddMonths(1)) { expected.Add(date); } CalendarDateTime.ClearCalendar(); CalendarDateTime.AddMonthlyDateEvent(testDayName, false, testDay, _endTestDate, _startTestDate); var actual = testDayName.EventDatesBetween(_endTestDate, _startTestDate); Assert.Equal(expected, actual); }
public void CountMonthly() { CalendarDateTime.ClearCalendar(); Assert.Equal(0, CalendarDateTime.CountMonthlyEvents); Assert.Equal(0, CalendarDateTime.CountEvents); CalendarDateTime.AddMonthlyDateEvent("m1", false, 1); Assert.Equal(1, CalendarDateTime.CountMonthlyEvents); Assert.Equal(1, CalendarDateTime.CountEvents); CalendarDateTime.AddMonthlyDateEvent("m2", false, 1); Assert.Equal(2, CalendarDateTime.CountMonthlyEvents); Assert.Equal(2, CalendarDateTime.CountEvents); CalendarDateTime.ClearCalendar(); Assert.Equal(0, CalendarDateTime.CountMonthlyEvents); Assert.Equal(0, CalendarDateTime.CountEvents); }
public void KeysEvents() { const string dated = "dated"; const string weekKey = "WeekKey"; const string yearlyKey = "YearlyKey"; const string monthlyKey = "monthlyKey"; CalendarDateTime.ClearCalendar(); CalendarDateTime.AddYearlyDateEvent(yearlyKey, false, 1, 2, false, false); CalendarDateTime.AddWeeklyInMonthEvent(weekKey, false, DayOfWeek.Friday); CalendarDateTime.AddDateEvent(dated, false, DateTime.Now); CalendarDateTime.AddMonthlyDateEvent(monthlyKey, true, 2); var expected = new List <string> { yearlyKey, weekKey, dated, monthlyKey }.OrderBy(s => s); var actual = CalendarDateTime.KeysEvents.ToList().OrderBy(s => s); Assert.Equal(expected, actual); }
public void AddMonthlyDayEventThrowsDuplicate() { CalendarDateTime.ClearCalendar(); CalendarDateTime.AddMonthlyDateEvent("1", true, 2); Assert.Throws <ArgumentException>(() => CalendarDateTime.AddMonthlyDateEvent("1", false, 2)); }
public void AddWeeklyEventEmptyEventThrows() { Assert.Throws <ArgumentNullException>(() => CalendarDateTime.AddMonthlyDateEvent("", true, 1)); }
public void AddMonthlyDayEventThrowsEmptyNullEvent() { Assert.Throws <ArgumentNullException>(() => CalendarDateTime.AddMonthlyDateEvent(null, false, 1)); Assert.Throws <ArgumentNullException>(() => CalendarDateTime.AddMonthlyDateEvent(string.Empty, false, 1)); }