public void DeleteEventsWithGivenTitle() { IEventsManager eventsManager = new EventsManagerFast(); eventsManager.AddEvent(sampleEvent); eventsManager.DeleteEventsByTitle(sampleEvent.Title); Assert.AreEqual(0, eventsManager.ListEvents(DateTime.MinValue, int.MaxValue).Count()); }
public void DeleteEventsByCaseInsensitiveTitle() { IEventsManager eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event { Date = DateTime.Now, Location = "Telerik Academy", Title = "High-Quality Code Exam", }); eventsManager.AddEvent(new Event { Date = DateTime.Now, Location = "Telerik Academy", Title = "HIGH-Quality CODE Exam", }); eventsManager.DeleteEventsByTitle("HIGH-Quality CODE Exam".ToLower()); Assert.AreEqual(0, eventsManager.ListEvents(DateTime.MinValue, int.MaxValue).Count()); }
public void AddDuplicateEvents() { IEventsManager eventsManager = new EventsManagerFast(); eventsManager.AddEvent(sampleEvent); eventsManager.AddEvent(sampleEvent); eventsManager.AddEvent(sampleEvent); Assert.AreEqual(3, eventsManager.ListEvents(DateTime.MinValue, int.MaxValue).Count()); }
public void TestAddEvent_When3EventsAdded() { EventsManagerFast manager = new EventsManagerFast(); //first event string titleCSharp = "C# exam"; var dateCSharp = DateTime.ParseExact( "2012-03-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string locationCSharp = "Home"; var evCSharp1 = new Event { date = dateCSharp, Title = titleCSharp, Location = locationCSharp, }; manager.AddEvent(evCSharp1); //second event string title = "C++ exam"; var dateCPlus = DateTime.ParseExact( "2011-02-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string locationCPlus = "Academy"; var evCPlus = new Event { date = dateCPlus, Title = title, Location = locationCPlus, }; //third event string titleCSharp2 = "C# exam"; var dateCSharp2 = DateTime.ParseExact( "2012-03-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string locationCSharp2 = "Home"; var evCSharp2 = new Event { date = dateCSharp2, Title = titleCSharp2, Location = locationCSharp2, }; manager.AddEvent(evCSharp2); var result = manager.ListEvents(dateCSharp, 2); int actual = result.Count(); Assert.AreEqual(2, actual); }
public void TestAddEvent_When1EventAdded() { var date = DateTime.ParseExact( "2012-03-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string title = "C# exam"; var ev = new Event { date = date, Title = title, Location = null, }; EventsManagerFast manager = new EventsManagerFast(); manager.AddEvent(ev); var result = manager.ListEvents(date, 1); int actual = result.Count(); Assert.AreEqual(1, actual); }
public void TestListEvents_WhenSingleEventIsAddedAndItIsAfterTheStartingDate_TheNumberOfDatesToListIsZero() { EventsManagerFast eventsManager = new EventsManagerFast(); DateTime yesterday = DateTime.Now.AddDays(-1); eventsManager.AddEvent(new Event(DateTime.Now, "Title")); IEnumerable<Event> events = eventsManager.ListEvents(yesterday, 0); int listedEventsCount = this.CountEvents(events); Assert.AreEqual(0, listedEventsCount); }
public void TestListEvents_WhenNoneEventsAreAdded() { EventsManagerFast eventsManager = new EventsManagerFast(); IEnumerable<Event> events = eventsManager.ListEvents(DateTime.Now, 10); int listedEventsCount = this.CountEvents(events); Assert.AreEqual(0, listedEventsCount); }
public void TestListEvents_WhenMultipleEventsAreAdded_TheNumberOfEventsToListIsZero() { EventsManagerFast eventsManager = new EventsManagerFast(); DateTime yesterday = DateTime.Now.AddDays(-1); int totalNumberOfEvents = 10; for (int i = 0; i < totalNumberOfEvents; i++) { eventsManager.AddEvent(new Event(DateTime.Now, "Title")); } IEnumerable<Event> events = eventsManager.ListEvents(yesterday, 0); int listedEventsCount = this.CountEvents(events); Assert.AreEqual(0, listedEventsCount); }
public void TestListEvents_WhenMultipleEventsAreAddedAndSomeOfThemAreAfterTheStartingDate() { EventsManagerFast eventsManager = new EventsManagerFast(); DateTime beforeTwoDays = DateTime.Now.AddDays(-2); DateTime yesterday = DateTime.Now.AddDays(-1); int totalNumberOfEvents = 20; int halfTheNumberOfEvent = totalNumberOfEvents / 2; for (int i = 0; i < halfTheNumberOfEvent; i++) { eventsManager.AddEvent(new Event(DateTime.Now, "Title")); } for (int i = 0; i < halfTheNumberOfEvent; i++) { eventsManager.AddEvent(new Event(beforeTwoDays, "Title")); } IEnumerable<Event> events = eventsManager.ListEvents(yesterday, totalNumberOfEvents); int listedEventsCount = this.CountEvents(events); Assert.AreEqual(halfTheNumberOfEvent, listedEventsCount); }
public void NoEventsWillBeListedWithDateFarInTheFuture() { IEventsManager eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 10, 00, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam", }); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 16, 30, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam", }); var dateCriteria = DateTime.MaxValue; Assert.AreEqual(0, eventsManager.ListEvents(dateCriteria, int.MaxValue).Count()); }
public void ListNoResultTest() { EventsManagerFast fastManager = new EventsManagerFast(); var firstDate = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event firstEvent = new Event(firstDate, "Party 1", "Sofia"); fastManager.AddEvent(firstEvent); var date = DateTime.ParseExact("2012-01-21T21:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var result = fastManager.ListEvents(date, 5); Assert.AreEqual(0, result.Count()); }
public void ListEventsCheckOrderTest() { EventsManagerFast fastManager = new EventsManagerFast(); var firstDate = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var secondDate = DateTime.ParseExact("2012-05-24T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var thirdDate = DateTime.ParseExact("2012-04-02T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var fourthDate = DateTime.ParseExact("2012-04-15T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event firstEvent = new Event(firstDate, "Party 1", "Sofia"); Event secondEvent = new Event(secondDate, "Party 2", "Burgas"); Event thirdEvent = new Event(thirdDate, "Party 3", "Varna"); Event fourthEvent = new Event(fourthDate, "Party 4", "Na selo"); fastManager.AddEvent(firstEvent); fastManager.AddEvent(secondEvent); fastManager.AddEvent(thirdEvent); fastManager.AddEvent(fourthEvent); var date = DateTime.ParseExact("2012-01-01T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var result = fastManager.ListEvents(date, 10); string[] expected = { "2012-01-21T20:00:00 | Party 1 | Sofia", "2012-04-02T20:00:00 | Party 3 | Varna", "2012-04-15T20:00:00 | Party 4 | Na selo", "2012-05-24T20:00:00 | Party 2 | Burgas" }; string[] actual = { result.First().ToString(), result.Skip(1).First().ToString(), result.Skip(2).First().ToString(), result.Skip(3).First().ToString() }; CollectionAssert.AreEqual(expected, actual); }
public void TestListEvents() { EventsManagerFast manager = new EventsManagerFast(); //first event string titleCSharp = "C# exam"; var dateCSharp = DateTime.ParseExact( "2012-03-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string locationCSharp = "Home"; var evCSharp1 = new Event { date = dateCSharp, Title = titleCSharp, Location = locationCSharp, }; manager.AddEvent(evCSharp1); //second event string title = "C++ exam"; var dateCPlus = DateTime.ParseExact( "2011-02-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string locationCPlus = "Academy"; var evCPlus = new Event { date = dateCPlus, Title = title, Location = locationCPlus, }; //third event string titleCSharp2 = "C# exam"; var dateCSharp2 = DateTime.ParseExact( "2012-03-26T09:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string locationCSharp2 = "Home"; var evCSharp2 = new Event { date = dateCSharp2, Title = titleCSharp2, Location = locationCSharp2, }; manager.AddEvent(evCSharp2); var dateToList = dateCSharp; IEnumerable<Event> actualList = manager.ListEvents(dateToList, 2).ToList(); List<Event> expectedList = new List<Event>(); expectedList.Add(evCSharp1); expectedList.Add(evCSharp2); bool areEqual = CompareLists(expectedList, (List<Event>)actualList); Assert.IsTrue(areEqual); }
public void ListEventsByDate() { IEventsManager eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 10, 00, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam Morning", }); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 16, 30, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam Evening", }); var dateCriteria = new DateTime(2013, 05, 20, 12, 00, 00); var result = eventsManager.ListEvents(dateCriteria, int.MaxValue).ToList(); Assert.AreEqual(1, result.Count); Assert.AreEqual("High-Quality Code Exam Evening", result[0].Title); }
public void TestListEvents_WhenSingleEventIsAddedAndItIsBeforeTheStartingDate() { EventsManagerFast eventsManager = new EventsManagerFast(); DateTime yesterday = DateTime.Now.AddDays(-1); eventsManager.AddEvent(new Event(yesterday, "Title")); IEnumerable<Event> events = eventsManager.ListEvents(DateTime.Today, 10); int listedEventsCount = this.CountEvents(events); Assert.AreEqual(0, listedEventsCount); }
public void TestListEventsOutOfRangeCount() { EventsManagerFast eventManager = new EventsManagerFast(); Event ev = new Event(); ev.Title = "C# course - 756828"; ev.Date = DateTime.ParseExact("2000-01-01T00:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); ev.Location = "Telerik academy"; eventManager.AddEvent(ev); eventManager.ListEvents(new DateTime(1999, 5, 20, 5, 20, 30), 9999); }
public void TestListEvents_WhenTheNumberOfEventsToListIsSmallerThanTheMatchingEvents() { EventsManagerFast eventsManager = new EventsManagerFast(); DateTime yesterday = DateTime.Now.AddDays(-1); int totalNumberOfEvents = 10; for (int i = 0; i < totalNumberOfEvents; i++) { eventsManager.AddEvent(new Event(DateTime.Now, "Title")); } IEnumerable<Event> events = eventsManager.ListEvents(yesterday, totalNumberOfEvents - 5); int listedEventsCount = this.CountEvents(events); Assert.AreEqual(totalNumberOfEvents - 5, listedEventsCount); }
public void TestListEventsWithDateAfterEvents() { EventsManagerFast eventManager = new EventsManagerFast(); Event ev = new Event(); ev.Title = "C# course - 756828"; ev.Date = DateTime.ParseExact("2000-01-01T00:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); ev.Location = "Telerik academy"; eventManager.AddEvent(ev); Event ev2 = new Event(); ev2.Title = "Chalga party"; ev2.Date = DateTime.ParseExact("2012-03-31T23:59:57", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); ev2.Location = "Sofia - 230340"; eventManager.AddEvent(ev2); Event ev3 = new Event(); ev3.Title = "C# course - 756828"; ev3.Date = DateTime.ParseExact("2019-01-01T00:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); ev3.Location = "Sofia - 230340"; eventManager.AddEvent(ev3); Event ev4 = new Event(); ev4.Title = "party Kiro"; ev4.Date = DateTime.ParseExact("2001-01-01T10:30:01", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); ev4.Location = "Sofia - 230340"; eventManager.AddEvent(ev4); IEnumerable<Event> events = eventManager.ListEvents(new DateTime(2050, 1, 1), 3); var counter = 0; foreach (var currentEvent in events) { counter++; } Assert.AreEqual(0, counter); }
public void ListMatchingEventsFirstOnlyTest() { EventsManagerFast fastManager = new EventsManagerFast(); var firstDate = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var secondDate = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var thirdDate = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var fourthDate = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event firstEvent = new Event(firstDate, "Sofia Party", "Sofia"); Event secondEvent = new Event(secondDate, "Burgas Party", "Burgas"); Event thirdEvent = new Event(thirdDate, "Varna Party", "Varna"); Event fourthEvent = new Event(fourthDate, "Na selo Party", "Na selo"); fastManager.AddEvent(firstEvent); fastManager.AddEvent(secondEvent); fastManager.AddEvent(thirdEvent); fastManager.AddEvent(fourthEvent); var date = DateTime.ParseExact("2012-01-20T21:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var result = fastManager.ListEvents(date, 1); Assert.AreEqual(1, result.Count()); Assert.AreSame(secondEvent, result.First()); // because Burgas is alphabetically first }
public void TestListEvents_WhenMultipleEventsAreAddedAndAllAreAfterTheStartingDate() { EventsManagerFast eventsManager = new EventsManagerFast(); DateTime yesterday = DateTime.Now.AddDays(-1); int totalNumberOfEvents = 10; for (int i = 0; i < totalNumberOfEvents; ++i) { eventsManager.AddEvent(new Event(DateTime.Now, "Title")); } IEnumerable<Event> events = eventsManager.ListEvents(yesterday, totalNumberOfEvents); int listedEventsCount = this.CountEvents(events); Assert.AreEqual(totalNumberOfEvents, listedEventsCount); }
public void ListSingleEventTest() { EventsManagerFast fastManager = new EventsManagerFast(); var firstDate = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event firstEvent = new Event(firstDate, "Party 1", "Sofia"); fastManager.AddEvent(firstEvent); var result = fastManager.ListEvents(firstDate, 1); // search for the same date Assert.AreEqual(1, result.Count()); Assert.AreSame(firstEvent, result.First()); }
public void ListEventsByDateAndLimitTheOutputCount() { IEventsManager eventsManager = new EventsManagerFast(); const int CountLimit = 2; eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 10, 00, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam", }); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 16, 30, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam", }); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 17, 30, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam", }); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 18, 30, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam", }); eventsManager.AddEvent(new Event { Date = new DateTime(2013, 05, 20, 19, 30, 00), Location = "Telerik Academy", Title = "High-Quality Code Exam", }); var dateCriteria = new DateTime(2013, 05, 20, 12, 00, 00); Assert.AreEqual(CountLimit, eventsManager.ListEvents(dateCriteria, CountLimit).Count()); }