public ListEvents ( System.DateTime date, int numberOfEventsToList ) : IEnumerable |
||
date | System.DateTime | |
numberOfEventsToList | int | |
Результат | IEnumerable |
public void ListOneEventTest() { string date1 = "2001-01-01T10:30:00"; DateTime eventDate1 = DateTime.ParseExact( date1, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event newEvent1 = new Event() { Date = eventDate1, Title = "PARTY", Location = null }; string date2 = "2001-01-01T10:30:00"; DateTime eventDate2 = DateTime.ParseExact( date2, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event newEvent2 = new Event() { Date = eventDate2, Title = "Trip", Location = "London" }; string date3 = "2001-01-01T10:30:00"; DateTime eventDate3 = DateTime.ParseExact( date3, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event newEvent3 = new Event() { Date = eventDate3, Title = "Trip", Location = "Moscow" }; EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(newEvent1); eventsManager.AddEvent(newEvent2); eventsManager.AddEvent(newEvent3); IEnumerable<Event> matchedEvents = eventsManager.ListEvents(eventDate1, 1); string[] matchedEventsStrings = GetTextRepresentations(matchedEvents); string[] expectedEventsStrings = new string[] { "2001-01-01T10:30:00 | PARTY" }; Assert.AreEqual(1, matchedEvents.Count()); CollectionAssert.AreEqual(expectedEventsStrings, matchedEventsStrings); }
public void AlphabeticalOrderOfListedEventsTest() { string[] dates = new string[] { "2002-01-01T10:30:00", "2011-01-01T22:16:00", "2002-01-01T10:30:00", "2011-01-01T22:16:00", "2011-01-01T22:16:00", "2011-01-01T22:16:00", }; string[] titles = new string[] { "Party", "Exam", "Trip", "Test", "Tennis", "Ski" }; string[] locations = new string[] { "Everywhere", "Telerik Academy", "London", "University", "Paris", null }; EventsManagerFast eventsManager = new EventsManagerFast(); for (int i = 0; i < 6; i++) { DateTime eventDate = DateTime.ParseExact( dates[i], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event newEvent = new Event() { Date = eventDate, Title = titles[i], Location = locations[i] }; eventsManager.AddEvent(newEvent); } DateTime eventDateToMatch = DateTime.ParseExact( "2011-01-01T22:16:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); IEnumerable<Event> matchedEvents = eventsManager.ListEvents(eventDateToMatch, 3); string[] matchedEventsStrings = GetTextRepresentations(matchedEvents); string[] expectedEventsStrings = new string[] { "2011-01-01T22:16:00 | Exam | Telerik Academy", "2011-01-01T22:16:00 | Ski", "2011-01-01T22:16:00 | Tennis | Paris", }; Assert.AreEqual(3, matchedEvents.Count()); CollectionAssert.AreEqual(expectedEventsStrings, matchedEventsStrings); }
public void ListMissingEventTest() { string date = "2001-01-01T10:30:00"; DateTime eventDate = DateTime.ParseExact( date, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event newEvent = new Event() { Date = eventDate, Title = "PARTY", Location = null }; EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(newEvent); IEnumerable<Event> matchedEvents = eventsManager.ListEvents(eventDate.AddDays(10), 1); string[] matchedEventsStrings = GetTextRepresentations(matchedEvents); Assert.AreEqual(0, matchedEvents.Count()); CollectionAssert.AreEqual(new string[0], matchedEventsStrings); }