public static void CalendarMethods() { CalendarModel calendar = new CalendarModel(); var emptyEventList = calendar.GetEventsAtDateTime(DateTime.UnixEpoch); Assert.AreEqual(emptyEventList.Count, 0); int startingHour = 0; int endingHour = 1; int startingMinutes = 0; int endingMinutes = 30; DateTime eventDate = DateTime.Today; CalendarEvent calendarEvent = new CalendarEvent("Test", DateTime.Today, startingHour, startingMinutes, endingHour, endingMinutes, "rodrigo", "description", ""); calendar.AddEvent(calendarEvent); int expectedEventsAtDateTime = 1; Assert.AreEqual(calendar.GetEventsAtDateTime(eventDate).Count, expectedEventsAtDateTime); int expectedEventsAfterEventRemoval = 0; calendar.RemoveEvent(calendarEvent); Assert.AreEqual(calendar.GetEventsAtDateTime(eventDate).Count, expectedEventsAfterEventRemoval); }
public static void NewCalendarHasNoEventsAtArbitraryDate() { CalendarModel calendar = new CalendarModel(); var emptyEventList = calendar.GetEventsAtDateTime(DateTime.UnixEpoch); Assert.AreEqual(emptyEventList.Count, 0); }
private void BuildCalendarDaySlots() { var daySlots = new List <string>(); for (var filledDays = 0; filledDays != GetDaysToFill(); filledDays++) { daySlots.Add(String.Empty); } for (var dayToAdd = 1; dayToAdd < DateTime.DaysInMonth(CurrentYear, CurrentMonth) + 1; dayToAdd++) { DateTime day = new DateTime(CurrentYear, CurrentMonth, dayToAdd); bool markEventsAtDay = false; foreach (var calendarEvent in calendar.GetEventsAtDateTime(day)) { List <string> relatedPeople = new List <string>(); relatedPeople.Add(calendarEvent.Owner); relatedPeople.AddRange(calendarEvent.InvitedUsers.Split(",")); if (relatedPeople.Contains(loggedUser)) { markEventsAtDay = true; break; } } if (markEventsAtDay) { daySlots.Add(String.Format(applicationCulture, "{0}*", dayToAdd.ToString(applicationCulture))); } else { daySlots.Add(dayToAdd.ToString(applicationCulture)); } } DaySlotList = daySlots; }
public List <CalendarEvent> GetEventsAtDateTime(DateTime pickedDate) { return(calendar.GetEventsAtDateTime(pickedDate)); }