public void AddSameEventsTest() { var eventManager = new EventsManagerFast(); string[] eventParameters = { "2010-01-01T00:00:00", "party Viki 2010" }; var command = new Command { CommandName = "AddEvent", Parameters = eventParameters }; var date = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string[] eventParametersTwo = { "2010-01-01T00:00:00", "party Viki 2010" }; var commandTwo = new Command { CommandName = "AddEvent", Parameters = eventParameters }; var dateTwo = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var theEvent = new Event { EventDate = date, EventTitle = command.Parameters[1], EventLocation = null, }; var theEvent2 = new Event { EventDate = dateTwo, EventTitle = commandTwo.Parameters[1], EventLocation = null, }; eventManager.AddEvent(theEvent); eventManager.AddEvent(theEvent2); var actual = eventManager.ListEvents(date, 5).Count(); int expexted = 2; Assert.AreEqual(expexted, actual); }
public void ListEmpty() { EventsManagerFast eventsManager = new EventsManagerFast(); int expected = 0; int actual = eventsManager.ListEvents(DateTime.MinValue, 1).Count(); Assert.AreEqual(expected, actual); }
public void AddSeveralEvents() { EventsManagerFast eventsManager = new EventsManagerFast(); Event ev1 = new Event { Title = "Sleep", //"2013-05-20T18:00:00" Date = new DateTime(2013, 5, 20, 18, 0, 0), Location = "At home", }; Event ev2 = new Event { Title = "Study", //"2013-05-20T18:00:00" Date = new DateTime(2013, 5, 20, 20, 0, 0), Location = "At home", }; Event ev3 = new Event { Title = "Eat", //"2013-05-20T18:00:00" Date = new DateTime(2013, 5, 20, 19, 00, 0), Location = "At home", }; eventsManager.AddEvent(ev1); eventsManager.AddEvent(ev2); eventsManager.AddEvent(ev3); int expected = 3; int actual = eventsManager.Count; Assert.AreEqual(expected, actual); var eventsList = eventsManager.ListEvents(new DateTime(2013, 5, 20, 18, 0, 0), 1); Assert.AreSame(ev1, eventsList.First()); eventsList = eventsManager.ListEvents(new DateTime(2013, 5, 20, 20, 0, 0), 1); Assert.AreSame(ev2, eventsList.First()); eventsList = eventsManager.ListEvents(new DateTime(2013, 5, 20, 19, 0, 0), 1); Assert.AreSame(ev3, eventsList.First()); }
public void AddOneEventThenListEvent() { DateTime date = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event event3Params = new Event(date, "party Viki", "home"); EventsManagerFast eventManager = new EventsManagerFast(); eventManager.AddEvent(event3Params); var actual = eventManager.ListEvents(date, 3).ToList(); Assert.AreEqual(1, actual.Count); }
public void AddTwoEventsThenDeleteOneAndList() { DateTime dateOne = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event event3Params = new Event(dateOne, "party Viki", "home"); Event event2Params = new Event(dateOne, "C# exam", null); EventsManagerFast eventManager = new EventsManagerFast(); eventManager.AddEvent(event2Params); eventManager.AddEvent(event3Params); int deletedCount = eventManager.DeleteEventsByTitle("C# exam"); var events = eventManager.ListEvents(dateOne, 3).ToList(); Assert.AreEqual(1, deletedCount); Assert.AreEqual(1, events.Count); }
public void AddTwoEventsThenListMissingEvent() { DateTime dateOne = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); DateTime dateTwo = DateTime.ParseExact("2013-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); Event event3Params = new Event(dateOne, "party Viki", "home"); Event event2Params = new Event(dateOne, "C# exam", null); EventsManagerFast eventManager = new EventsManagerFast(); eventManager.AddEvent(event2Params); eventManager.AddEvent(event3Params); var events = eventManager.ListEvents(dateTwo, 3).ToList(); //Both are valid assertions //only one may do the job Assert.IsFalse(events.Any()); Assert.AreEqual(0, events.Count); }
public void AddOneEvent() { EventsManagerFast eventsManager = new EventsManagerFast(); Event ev = new Event { Title = "Sleep", Date = new DateTime(2013, 5, 20, 18, 0, 0), Location = "At home", }; eventsManager.AddEvent(ev); int expected = 1; int actual = eventsManager.Count; Assert.AreEqual(expected, actual); var events = eventsManager.ListEvents(new DateTime(2013, 5, 20, 18, 0, 0), 1); Assert.AreSame(ev, events.First()); }
public void ListEventsWithMoreMatchingThenTheRequstedCount() { var date = DateTime.ParseExact("2001-01-01T12:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var date1 = DateTime.ParseExact("2011-01-01T12:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var calendarEvent1 = new CalendarEvent { Date = date, Title = "party Lora", Location = null, }; var calendarEvent2 = new CalendarEvent { Date = date, Title = "party Lora", Location = null, }; var calendarEvent3 = new CalendarEvent { Date = date1, Title = "party Lora", Location = "Sofia", }; EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(calendarEvent3); eventsManager.AddEvent(calendarEvent1); eventsManager.AddEvent(calendarEvent2); var matchedEvents = eventsManager.ListEvents(date, 1).ToList(); Assert.AreEqual(1, matchedEvents.Count); }
public void AddEventsThenCheckListIfSortedByLocation() { DateTime dateOne = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); EventsManagerFast eventManager = new EventsManagerFast(); eventManager.AddEvent(new Event(dateOne, "party Viki", "zoo")); eventManager.AddEvent(new Event(dateOne, "party Viki", "home")); eventManager.AddEvent(new Event(dateOne, "party Viki", "alone")); eventManager.AddEvent(new Event(dateOne, "party Viki", "home")); var events = eventManager.ListEvents(dateOne, 4).ToList(); Assert.AreEqual(events[0].Location, "alone"); Assert.AreEqual(events[1].Location, "home"); Assert.AreEqual(events[2].Location, "home"); Assert.AreEqual(events[3].Location, "zoo"); }
public void CheckSortingOrder() { EventsManagerFast eventsManager = new EventsManagerFast(); Event notInListEv = new Event { Title = "something", Date = new DateTime(1999, 1, 20, 18, 0, 1), Location = "somewhere", }; Event firstEv = new Event { Title = "Eat", Date = new DateTime(2005, 1, 1, 1, 1, 1), Location = "At home", }; Event secondEv = new Event { Title = "Eat", Date = new DateTime(2006, 1, 20, 18, 0, 1), Location = "At home", }; Event thirdEv = new Event { Title = "Play", Date = new DateTime(2006, 1, 20, 18, 0, 1), Location = "At home", }; Event fourthEv = new Event { Title = "Play", Date = new DateTime(2006, 1, 20, 18, 0, 1), Location = "Outside", }; Event fifthEv = new Event { Title = "Play", Date = new DateTime(2006, 1, 20, 18, 0, 1), Location = "Somewhere else", }; eventsManager.AddEvent(fifthEv); eventsManager.AddEvent(thirdEv); eventsManager.AddEvent(notInListEv); eventsManager.AddEvent(secondEv); eventsManager.AddEvent(firstEv); eventsManager.AddEvent(fourthEv); var listedEvents = eventsManager.ListEvents(new DateTime(2001, 5, 15, 19, 0, 0), 5); Assert.AreEqual(5, listedEvents.Count()); Assert.AreSame(firstEv, listedEvents.First()); Assert.AreSame(secondEv, listedEvents.Skip(1).First()); Assert.AreSame(thirdEv, listedEvents.Skip(2).First()); Assert.AreSame(fourthEv, listedEvents.Skip(3).First()); Assert.AreSame(fifthEv, listedEvents.Skip(4).First()); }
public void List4EventsWith2Matching() { EventsManagerFast eventsManager = new EventsManagerFast(); Event ev1 = new Event { Title = "Eat", Date = new DateTime(2013, 5, 20, 18, 0, 0), Location = "At home", }; Event ev2 = new Event { Title = "Sleep", Date = new DateTime(2013, 1, 20, 18, 0, 0), Location = "At home", }; Event ev3 = new Event { Title = "Play", Date = new DateTime(2010, 1, 20, 18, 0, 0), Location = "At home", }; eventsManager.AddEvent(ev1); eventsManager.AddEvent(ev2); eventsManager.AddEvent(ev3); var listedEvents = eventsManager.ListEvents(new DateTime(2011, 5, 15, 18, 0, 0), 4); Assert.AreEqual(2, listedEvents.Count()); Assert.AreSame(ev2, listedEvents.First()); Assert.AreSame(ev1, listedEvents.Skip(1).First()); }
public void ListOneMatchingElementFromSeveralNonMatching() { EventsManagerFast eventsManager = new EventsManagerFast(); Event ev1 = new Event { Title = "Eat", Date = new DateTime(2013, 5, 20, 18, 0, 0), Location = "At home", }; Event ev2 = new Event { Title = "Sleep", Date = new DateTime(2013, 1, 20, 18, 0, 0), Location = "At home", }; Event ev3 = new Event { Title = "Eat", Date = new DateTime(2013, 4, 20, 18, 0, 0), Location = "At home", }; eventsManager.AddEvent(ev1); eventsManager.AddEvent(ev2); eventsManager.AddEvent(ev3); var listedEvents = eventsManager.ListEvents(new DateTime(2013, 5, 15, 18, 0, 0), 1); Assert.AreEqual(1, listedEvents.Count()); Assert.AreSame(ev1, listedEvents.First()); }
public void ListMatchingElementWithZeroCount() { EventsManagerFast eventsManager = new EventsManagerFast(); Event ev = new Event { Title = "Sleep", Date = new DateTime(2013, 5, 20, 18, 0, 0), Location = "At home", }; eventsManager.AddEvent(ev); var listedEvents = eventsManager.ListEvents(new DateTime(2013, 5, 15, 18, 0, 0), 0); Assert.AreEqual(0, listedEvents.Count()); }
public void ListEventFourEventDisplayTwoTest() { var eventManager = new EventsManagerFast(); string[] eventParameters = { "2012-01-21T20:00:00", "party Viki", "home" }; var command = new Command { CommandName = "AddEvent", Parameters = eventParameters }; var date = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string[] eventParametersOne = { "2012-01-21T20:00:00", "C# exam" }; var commandOne = new Command { CommandName = "AddEvent", Parameters = eventParametersOne }; var dateOne = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string[] eventParametersTwo = { "2012-01-21T20:00:00", "C# exam" }; var commandTwo = new Command { CommandName = "AddEvent", Parameters = eventParametersTwo }; var dateTwo = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); string[] eventParametersThree = { "2012-01-21T20:00:00", "C# exam" }; var commandThree = new Command { CommandName = "AddEvent", Parameters = eventParametersThree }; var dateThree = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var theEvent = new Event { EventDate = date, EventTitle = command.Parameters[1], EventLocation = command.Parameters[2], }; var theEventOne = new Event { EventDate = dateOne, EventTitle = commandOne.Parameters[1], EventLocation = null }; var theEventTwo = new Event { EventDate = dateTwo, EventTitle = commandTwo.Parameters[1], EventLocation = null, }; var theEventThree = new Event { EventDate = dateThree, EventTitle = commandThree.Parameters[1], EventLocation = null, }; eventManager.AddEvent(theEvent); eventManager.AddEvent(theEventOne); eventManager.AddEvent(theEventTwo); eventManager.AddEvent(theEventThree); StringBuilder expected = new StringBuilder(); expected.AppendLine("2012-01-21T20:00:00 | C# exam"); expected.AppendLine("2012-01-21T20:00:00 | C# exam"); string expectedToString = expected.ToString(); StringBuilder actual = new StringBuilder(); var currentCommand = 2; var events = eventManager.ListEvents(date, currentCommand).ToList(); foreach (var e in events) { actual.AppendLine(e.ToString()); } string actualToString = actual.ToString(); Assert.AreEqual(expectedToString, actualToString); }
public void AddHundredSameEventTest() { var eventManager = new EventsManagerFast(); string[] eventParameters = { "2012-01-21T20:00:00", "party Viki", "home" }; var command = new Command { CommandName = "AddEvent", Parameters = eventParameters }; var date = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var theEvent = new Event { EventDate = date, EventTitle = command.Parameters[1], EventLocation = command.Parameters[2], }; for (int i = 0; i < 100; i++) { eventManager.AddEvent(theEvent); } int actual = eventManager.ListEvents(date, 100).Count(); Console.WriteLine(eventManager.NumberOfEventsInList); Assert.AreEqual(100, actual); }
public void ListWithSortingByMissingLocation() { EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event(DateTime.MinValue, "a")); eventsManager.AddEvent(new Event(DateTime.MinValue, "a", "a")); var result = eventsManager.ListEvents(DateTime.MinValue, int.MaxValue); Assert.AreEqual(result.ElementAt(0).Location, null); Assert.AreEqual(result.ElementAt(1).Location, "a"); }
public void ListWithFilterSomeElements() { EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki")); eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki")); eventsManager.AddEvent(new Event(new DateTime(2010, 12, 10), "party Gosho")); eventsManager.AddEvent(new Event(new DateTime(2010, 12, 10), "party Gosho")); eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov")); eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov")); int expected = 3; int actual = eventsManager.ListEvents(new DateTime(2010, 12, 10), 3).Count(); Assert.AreEqual(expected, actual); }
public void AddEventsThenCheckListIfSortedByManyCriterias() { DateTime dateOne = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); DateTime dateTwo = DateTime.ParseExact("2013-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); EventsManagerFast eventManager = new EventsManagerFast(); eventManager.AddEvent(new Event(dateOne, "party viki", "home1")); eventManager.AddEvent(new Event(dateOne, "party Asen", "home3")); eventManager.AddEvent(new Event(dateTwo, "party Viki", "home5")); eventManager.AddEvent(new Event(dateOne, "party Viki", "home2")); eventManager.AddEvent(new Event(dateTwo, "party Viki", "home4")); var events = eventManager.ListEvents(dateOne, 5).ToList(); Assert.AreEqual(events[0].Location, "home3"); Assert.AreEqual(events[1].Location, "home2"); Assert.AreEqual(events[2].Location, "home1"); Assert.AreEqual(events[3].Location, "home4"); Assert.AreEqual(events[4].Location, "home5"); }
public void TestMethodListSingleEventWithNotAccurateCount() { EventsManagerFast eventManagerFast = new EventsManagerFast(); Event ev = new Event(); ev.Title = "party Viki"; ev.DateTime = DateTime.Parse("2012-01-21T20:00:00"); ev.Location = "home"; eventManagerFast.AddEvent(ev); var eventsListedCount = eventManagerFast.ListEvents(ev.DateTime, 5); Assert.AreEqual(1, eventsListedCount.Count()); }
public void TestMethodListMultipleEvents() { EventsManagerFast eventManagerFast = new EventsManagerFast(); Event firstEvent = new Event(); firstEvent.Title = "party Viki"; firstEvent.DateTime = DateTime.Parse("2012-01-21T20:00:00"); firstEvent.Location = "home"; Event secondEvent = new Event(); secondEvent.Title = "C# exam"; secondEvent.DateTime = DateTime.Parse("2012-05-25T10:00:00"); secondEvent.Location = "Telerik"; Event thirdEvent = new Event(); thirdEvent.Title = "party"; thirdEvent.DateTime = DateTime.Parse("2012-08-23T22:00:00"); thirdEvent.Location = "Biad"; eventManagerFast.AddEvent(firstEvent); eventManagerFast.AddEvent(secondEvent); eventManagerFast.AddEvent(thirdEvent); var eventsListedCount = eventManagerFast.ListEvents(DateTime.Parse("2011-07-24T10:00:00"), 5); Assert.AreEqual(3, eventsListedCount.Count()); }
public void ListWithSortingByTitle() { EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event(DateTime.MinValue, "b")); eventsManager.AddEvent(new Event(DateTime.MinValue, "a")); var result = eventsManager.ListEvents(DateTime.MinValue, int.MaxValue); Assert.AreEqual(result.ElementAt(0).Title, "a"); Assert.AreEqual(result.ElementAt(1).Title, "b"); }
public void ListEventsWithNegativeCount() { EventsManagerFast eventsManager = new EventsManagerFast(); Event ev = new Event { Title = "Sleep", Date = new DateTime(2013, 5, 20, 18, 0, 0), Location = "At home", }; eventsManager.AddEvent(ev); eventsManager.ListEvents(DateTime.Now, -1); }
public void ListComplex() { EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event(new DateTime(2010, 12, 10), "party Gosho", null)); eventsManager.AddEvent(new Event(new DateTime(2010, 12, 10), "party Gosho", "home")); eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki", null)); eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki", "work")); eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov", null)); eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov", "telerik")); var result = eventsManager.ListEvents(new DateTime(2010, 12, 10), 3); int expected = 3; int actual = result.Count(); Assert.AreEqual(expected, actual); Assert.AreEqual(result.ElementAt(0).Location, null); Assert.AreEqual(result.ElementAt(1).Location, "home"); Assert.AreEqual(result.ElementAt(2).Location, null); }
public void EmptyEventsList() { EventsManagerFast eventsManager = new EventsManagerFast(); var eventsList = eventsManager.ListEvents(new DateTime(2020, 10, 10, 10, 10, 10), 5); Assert.AreEqual(0, eventsList.Count()); }
public void ListWithLessElements() { EventsManagerFast eventsManager = new EventsManagerFast(); eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki")); eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki")); eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov")); eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov")); int expected = 1; int actual = eventsManager.ListEvents(DateTime.MaxValue, 1).Count(); Assert.AreEqual(expected, actual); }
public void ListEventTwoEventTest() { var eventManager = new EventsManagerFast(); string[] eventParameters = { "2010-01-01T00:00:00", "party Viki 2010" }; var command = new Command { CommandName = "AddEvent", Parameters = eventParameters }; var date = DateTime.ParseExact(command.Parameters[0], "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture); var theEvent = new Event { EventDate = date, EventTitle = command.Parameters[1], EventLocation = null, }; eventManager.AddEvent(theEvent); eventManager.AddEvent(theEvent); eventManager.AddEvent(theEvent); int expected = 2; int actual = 0; var currentCommand = 2; var events = eventManager.ListEvents(date, currentCommand).ToList(); foreach (var e in events) { actual++; } Assert.AreEqual(expected, actual); }