public void TestAddMultipleSameDateEvents()
        {
            EventsManagerFast eventManager = new EventsManagerFast();

            Event ev = new Event();

            ev.Title    = "Rock party - 407026";
            ev.Date     = DateTime.ParseExact("2001-01-01T08:30:03", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev.Location = "home - 681328";
            eventManager.AddEvent(ev);

            Event ev2 = new Event();

            ev2.Title    = "Chalga party";
            ev2.Date     = DateTime.ParseExact("2001-01-01T08:30:03", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev2.Location = "- 235165";
            eventManager.AddEvent(ev2);

            Event ev3 = new Event();

            ev3.Title    = "Party LORA";
            ev3.Date     = DateTime.ParseExact("2001-01-01T08:30:03", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev3.Location = "at school - 4795";
            eventManager.AddEvent(ev3);

            Assert.AreEqual(1, eventManager.EventsByDateCount);
            Assert.AreEqual(3, eventManager.EventsByTitleCount);
        }
Exemple #2
0
        public void ListEventsWithMatchingLessThenTheRequestedCountAndOtherUnmatching()
        {
            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);
            CalendarEvent calendarEvent = new CalendarEvent();

            calendarEvent.Title = "Party";
            calendarEvent.Date  = date;

            var calendarEvent1 = new CalendarEvent
            {
                Date     = date,
                Title    = "party Lora",
                Location = null,
            };

            var calendarEvent2 = new CalendarEvent
            {
                Date     = date1,
                Title    = "party Lora",
                Location = null,
            };

            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(calendarEvent);
            eventsManager.AddEvent(calendarEvent1);
            eventsManager.AddEvent(calendarEvent2);

            var matchedEvents = eventsManager.ListEvents(date1, 3).ToList();

            Assert.AreEqual(1, matchedEvents.Count);
        }
        public void TestAddMultipleEvents()
        {
            EventsManagerFast eventManager = new EventsManagerFast();

            Event ev = new Event();

            ev.Title    = "Rock party - 407026";
            ev.Date     = DateTime.ParseExact("2012-03-31T23:59:57", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev.Location = "home - 681328";
            eventManager.AddEvent(ev);

            Event ev2 = new Event();

            ev2.Title    = "party Lora - 198672";
            ev2.Date     = DateTime.ParseExact("2001-01-01T10:30:03", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev2.Location = "- 235165";
            eventManager.AddEvent(ev2);

            Event ev3 = new Event();

            ev3.Title    = "Chalga party - 974464";
            ev3.Date     = DateTime.ParseExact("2001-01-01T10:30:01", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev3.Location = "at school - 4795";
            eventManager.AddEvent(ev3);

            Assert.AreEqual(3, eventManager.EventsByTitleCount);
        }
Exemple #4
0
        public void DeleteEventDuplicateCommandInEventManager()
        {
            CalendarEvent calendarEvent = new CalendarEvent();

            calendarEvent.Title = "Party";

            var date           = DateTime.ParseExact("2001-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,
            };

            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(calendarEvent);
            eventsManager.AddEvent(calendarEvent);
            eventsManager.AddEvent(calendarEvent1);
            eventsManager.AddEvent(calendarEvent2);

            Assert.AreEqual(eventsManager.CurrentEventsCount, 4);

            eventsManager.DeleteEventsByTitle("party Lora");
            Assert.AreEqual(eventsManager.CurrentEventsCount, 2);
        }
        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);
        }
Exemple #6
0
        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());
        }
Exemple #7
0
        public void DeleteNonMatchingEvent()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event()
            {
                Title    = "not sleeping",
                Date     = new DateTime(2011, 10, 10, 10, 10, 10),
                Location = "Sofia"
            });
            eventsManager.AddEvent(new Event()
            {
                Title    = "Eating",
                Date     = new DateTime(2011, 10, 10, 10, 10, 10),
                Location = "Sofia"
            });
            eventsManager.AddEvent(new Event()
            {
                Title    = "Walking",
                Date     = new DateTime(2011, 10, 10, 10, 10, 10),
                Location = "Sofia"
            });

            int expected = 0;
            int actual   = eventsManager.DeleteEventsByTitle("Sleeping");

            Assert.AreEqual(expected, actual);
        }
Exemple #8
0
        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());
        }
Exemple #9
0
        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 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 AddDuplicateValue()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki"));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki"));

            int expected = 2;
            int actual   = eventsManager.Count;

            Assert.AreEqual(expected, actual);
        }
        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 AddDuplicateValue()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki"));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki"));

            int expected = 2;
            int actual = eventsManager.Count;

            Assert.AreEqual(expected, actual);
        }
        public void AddTwoEventsThenListEvent()
        {
            DateTime date = DateTime.ParseExact("2012-01-21T20:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            Event event3Params = new Event(date, "party Viki", "home");
            Event event2Params = new Event(date, "C# exam", null);

            EventsManagerFast eventManager = new EventsManagerFast();
            eventManager.AddEvent(event2Params);
            eventManager.AddEvent(event3Params);
            var actual = eventManager.ListEvents(date, 3).ToList();
            Assert.AreEqual(2, actual.Count);
        }
        public void DeleteLowerCase()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));

            int expected = 3;
            int actual   = eventsManager.DeleteEventsByTitle("PARTY GOSHO");

            Assert.AreEqual(expected, actual);
        }
Exemple #16
0
        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());
        }
Exemple #17
0
        public void TestDeleteEventsByTitle_WhenMultipleEventsAreAddedAndOnlyOneMatches()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            for (int i = 0; i < 10; i++)
            {
                eventsManager.AddEvent(new Event(DateTime.Now, "Title"));
            }

            eventsManager.AddEvent(new Event(DateTime.Now, "Title1"));
            int numberOfDeletedEvents = eventsManager.DeleteEventsByTitle("Title1");

            Assert.AreEqual(1, numberOfDeletedEvents);
        }
Exemple #18
0
        public void NoEventsWillBeListedWhenCountIsZero()
        {
            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.MinValue;

            Assert.AreEqual(0, eventsManager.ListEvents(dateCriteria, 0).Count());
        }
        public void ListSingle()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            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.MinValue, 1).Count();

            Assert.AreEqual(expected, actual);
        }
Exemple #20
0
        public void AddTwoEventsTest()
        {
            CalendarEvent calendarEvent = new CalendarEvent();

            calendarEvent.Title = "Party";
            CalendarEvent calendarEvent1 = new CalendarEvent();

            calendarEvent1.Title = "ivan";
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(calendarEvent);
            eventsManager.AddEvent(calendarEvent1);

            Assert.AreEqual(2, eventsManager.CurrentEventsCount);
        }
        public void ListWithFilterNoElements()
        {
            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"));

            int expected = 0;
            int actual   = eventsManager.ListEvents(DateTime.MaxValue, int.MaxValue).Count();

            Assert.AreEqual(expected, actual);
        }
        public void TestAddEventDublicates()
        {
            DateTime          now          = DateTime.Now;
            Event             currentEvent = new Event(now, "Test event", "Nqkade si");
            EventsManagerFast manager      = new EventsManagerFast();

            manager.AddEvent(currentEvent);
            manager.AddEvent(currentEvent);

            var countTitles = manager.TitlesList["Test event".ToLowerInvariant()];
            var countDates  = manager.DatesList[now];

            Assert.AreEqual(2, countTitles.Count);
            Assert.AreEqual(2, countDates.Count);
        }
        public void TestMethodAddDuplicatedEvents()
        {
            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 = "party Viki";
            secondEvent.DateTime = DateTime.Parse("2012-01-21T20:00:00");
            secondEvent.Location = "home";
            EventsManagerFast eventManagerFast = new EventsManagerFast();
            eventManagerFast.AddEvent(firstEvent);
            eventManagerFast.AddEvent(secondEvent);

            Assert.AreEqual(2, eventManagerFast.Count);
        }
Exemple #24
0
        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);
        }
Exemple #25
0
        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());
        }
Exemple #26
0
        public void AddSameCalendarEventDuplicatedEvents()
        {
            var date          = DateTime.ParseExact("2001-01-01T12:00:00", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            var calendarEvent = new CalendarEvent
            {
                Date     = date,
                Title    = "party Lora",
                Location = null,
            };

            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(calendarEvent);
            eventsManager.AddEvent(calendarEvent);

            Assert.AreEqual(eventsManager.CurrentEventsCount, 2);
        }
Exemple #27
0
        public void DeleteEventsWithGivenNoMatchingTitle()
        {
            IEventsManager eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(sampleEvent);
            eventsManager.DeleteEventsByTitle("High");
            Assert.AreEqual(1, eventsManager.ListEvents(DateTime.MinValue, int.MaxValue).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 AddTwoEventsThenDeleteInvalidEventAndList()
        {
            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("Baba Meca");

            var events = eventManager.ListEvents(dateOne, 3).ToList();

            Assert.AreEqual(0, deletedCount);
            Assert.AreEqual(2, events.Count);
        }
        public void TestListedElementsWithMultipleMatchMoreThanCountAndFewNonMatching()
        {
            DateTime          now          = DateTime.Now;
            Event             currentEvent = new Event(now, "Test event", "Nqkade si");
            Event             otherEvent   = new Event(now.AddHours(-10), "Test other event", "Nqkade si");
            Event             anotherEvent = new Event(now.AddHours(-20), "Test another event", "Nqkade si");
            EventsManagerFast manager      = new EventsManagerFast();

            manager.AddEvent(currentEvent);
            manager.AddEvent(currentEvent);
            manager.AddEvent(otherEvent);
            manager.AddEvent(anotherEvent);

            var selected = manager.ListEvents(now.AddHours(-30), 10).ToList();

            Assert.AreEqual(4, selected.Count);
        }
        public void TestListedElementsNoMatch()
        {
            DateTime          now          = DateTime.Now;
            Event             currentEvent = new Event(now, "Test event", "Nqkade si");
            Event             otherEvent   = new Event(now.AddHours(-10), "Test other event", "Nqkade si");
            Event             anotherEvent = new Event(now.AddHours(-20), "Test another event", "Nqkade si");
            EventsManagerFast manager      = new EventsManagerFast();

            manager.AddEvent(currentEvent);
            manager.AddEvent(currentEvent);
            manager.AddEvent(otherEvent);
            manager.AddEvent(anotherEvent);

            var selected = manager.ListEvents(now.AddHours(10), 10).ToList();

            Assert.AreEqual(0, selected.Count);
        }
        public void TestMethodAddEventsOnlyWithTitle()
        {
            Event ev = new Event();
            ev.Title = "party Viki";
            EventsManagerFast eventManagerFast = new EventsManagerFast();
            eventManagerFast.AddEvent(ev);

            Assert.AreEqual("party Viki", ev.Title);
        }
 public void TestMethodAddEventsWithoutDateTime()
 {
     EventsManagerFast eventManagerFast = new EventsManagerFast();
     Event ev = new Event();
     ev.Title = "party number Viki";
     ev.Location = "home";
     eventManagerFast.AddEvent(ev);
     Assert.AreEqual(1, eventManagerFast.Count);
 }
        public void DeleteEmpty()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));

            int expected = 0;
            int actual   = eventsManager.DeleteEventsByTitle("party Nakov");

            Assert.AreEqual(expected, actual);

            int expectedCount = 3;
            int actualCount   = eventsManager.Count;

            Assert.AreEqual(expectedCount, actualCount);
        }
        public void AddSingleAndDuplicate()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki"));

            eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov"));
            eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov"));

            Event @event = new Event(DateTime.MinValue, "party Pesho");
            eventsManager.AddEvent(@event);
            eventsManager.AddEvent(@event);

            int expected = 5;
            int actual = eventsManager.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 AddSingleAndDuplicate()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Viki"));

            eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov"));
            eventsManager.AddEvent(new Event(DateTime.MaxValue, "party Nakov"));

            Event @event = new Event(DateTime.MinValue, "party Pesho");

            eventsManager.AddEvent(@event);
            eventsManager.AddEvent(@event);

            int expected = 5;
            int actual   = eventsManager.Count;

            Assert.AreEqual(expected, actual);
        }
Exemple #38
0
        public void TestDeleteEventsByTitle_WhenSingleEventIsAddedAndDoesNotMatch()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.Now, "Title"));

            int numberOfDeletedEvents = eventsManager.DeleteEventsByTitle("OtherTitle");

            Assert.AreEqual(0, numberOfDeletedEvents);
        }
        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 TestDeleteEvent()
        {
            DateTime          now          = DateTime.Now;
            Event             currentEvent = new Event(now, "Test event", "Nqkade si");
            Event             otherEvent   = new Event(now.AddHours(1), "Test other event", "Nqkade si");
            Event             anotherEvent = new Event(now.AddHours(2), "Test another event", "Nqkade si");
            EventsManagerFast manager      = new EventsManagerFast();

            manager.AddEvent(currentEvent);
            manager.AddEvent(currentEvent);
            manager.AddEvent(otherEvent);
            manager.AddEvent(anotherEvent);

            int deleted = manager.DeleteEventsByTitle("Test event");

            Assert.AreEqual(2, deleted);
            Assert.AreEqual(2, manager.DatesList.Count);
            Assert.AreEqual(2, manager.TitlesList.Count);
        }
        public void TestMethodAdd500DuplicatedEvents()
        {
            EventsManagerFast eventManagerFast = new EventsManagerFast();
            for (int i = 0; i < 500; i++)
            {
                Event ev = new Event();
                ev.Title = "party Viki";
                ev.DateTime = DateTime.Parse("2012-01-21T20:00:00");
                ev.Location = "home";
                eventManagerFast.AddEvent(ev);
            }

            Assert.AreEqual(500, eventManagerFast.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 DeleteDouplicatingEvents()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            eventsManager.AddEvent(new Event()
            {
                Title = "Sleeping",
                Date = new DateTime(2011, 10, 10, 10, 10, 10),
                Location = "Sofia"
            });
            eventsManager.AddEvent(new Event()
            {
                Title = "Sleeping",
                Date = new DateTime(2012, 10, 10, 10, 10, 10),
                Location = "Sofia"
            });
            eventsManager.AddEvent(new Event()
            {
                Title = "Eating",
                Date = new DateTime(2011, 10, 10, 12, 10, 10),
                Location = "Sofia"
            });
            eventsManager.AddEvent(new Event()
            {
                Title = "Walking",
                Date = new DateTime(2011, 10, 10, 00, 10, 10),
                Location = "Sofia"
            });

            int expected = 2;
            int actual = eventsManager.DeleteEventsByTitle("Sleeping");
            Assert.AreEqual(expected, actual);

            expected = 0;
            actual = eventsManager.DeleteEventsByTitle("Sleeping");
            Assert.AreEqual(expected, actual);
        }
        public void DeleteEventsByGivenNullTitle()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            eventsManager.AddEvent(new Event()
            {
                Title = "Sleeping",
                Date = new DateTime(2011, 10, 10, 10, 10, 10),
                Location = "Sofia"
            });

            eventsManager.DeleteEventsByTitle(null);
        }
        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 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 DeleteLowerCase()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));

            int expected = 3;
            int actual = eventsManager.DeleteEventsByTitle("PARTY GOSHO");

            Assert.AreEqual(expected, actual);
        }
        public void AddSeveralEventsSomeWithDuplicateTitles()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            Event ev1 = new Event
            {
                Title = "Sleep",
                //"2013-05-20T18:00:00"
                Date = new DateTime(2013, 5, 20, 20, 0, 0),
                Location = "Paris",
            };

            Event ev2 = new Event
            {
                Title = "Sleep",
                //"2013-05-20T18:00:00"
                Date = new DateTime(2013, 4, 20, 20, 0, 0),
                Location = "London",
            };

            Event ev3 = new Event
            {
                Title = "Sleep",
                //"2013-05-20T18:00:00"
                Date = new DateTime(2013, 9, 20, 20, 15, 0),
                Location = "Sofia",
            };

            Event ev4 = new Event
            {
                Title = "Eat",
                //"2013-05-20T18:00:00"
                Date = new DateTime(2013, 11, 20, 20, 15, 0),
                Location = "Sofia",
            };

            Event ev5 = new Event
            {
                Title = "Work",
                //"2013-05-20T18:00:00"
                Date = new DateTime(2013, 9, 1, 10, 15, 0),
                Location = "Sofia",
            };

            Event ev6 = new Event
            {
                Title = "Play football",
                //"2013-05-20T18:00:00"
                Date = new DateTime(2013, 1, 1, 14, 35, 0),
                Location = "Sofia",
            };

            eventsManager.AddEvent(ev1);
            eventsManager.AddEvent(ev2);
            eventsManager.AddEvent(ev3);
            eventsManager.AddEvent(ev4);
            eventsManager.AddEvent(ev4);
            eventsManager.AddEvent(ev5);
            eventsManager.AddEvent(ev6);

            int expected = 7;
            int actual = eventsManager.Count;
            Assert.AreEqual(expected, actual);
        }
        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 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 TestAddingNullEvent()
 {
     EventsManagerFast eventsManager = new EventsManagerFast();
     eventsManager.AddEvent(null);
 }
        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 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 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 DeleteMultiple()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Gosho", null));
            
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Nakov", null));
            eventsManager.AddEvent(new Event(DateTime.MinValue, "party Nakov", null));

            int expected = 2;
            int actual = eventsManager.DeleteEventsByTitle("party Nakov");

            Assert.AreEqual(expected, actual);

            int expectedCount = 3;
            int actualCount = eventsManager.Count;
            Assert.AreEqual(expectedCount, actualCount);
        }
        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 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 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");
        }