Exemplo n.º 1
0
        public void DeleteSingleEvent()
        {
            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    = "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 = 1;
            int actual   = eventsManager.DeleteEventsByTitle("Sleeping");

            Assert.AreEqual(expected, actual);

            expected = 0;
            actual   = eventsManager.DeleteEventsByTitle("Sleeping");
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void TestDeleteEventsByTitle_WhenNoEevntsAreAdded()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            int numberOfDeletedEvents       = eventsManager.DeleteEventsByTitle("Title");

            Assert.AreEqual(0, numberOfDeletedEvents);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void DeleteEventFromEmptyEventManager()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            eventsManager.DeleteEventsByTitle("");

            Assert.AreEqual(eventsManager.CurrentEventsCount, 0);
        }
Exemplo n.º 5
0
        public void DeleteEventsWithGivenNoMatchingTitle()
        {
            IEventsManager eventsManager = new EventsManagerFast();

            eventsManager.AddEvent(sampleEvent);
            eventsManager.DeleteEventsByTitle("High");
            Assert.AreEqual(1, eventsManager.ListEvents(DateTime.MinValue, int.MaxValue).Count());
        }
Exemplo n.º 6
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 TestDoubleDelete()
        {
            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");
            int deletedAgain = manager.DeleteEventsByTitle("Test event");

            Assert.AreEqual(2, deleted);
            Assert.AreEqual(0, deletedAgain);
        }
        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);
        }
Exemplo n.º 9
0
        public void DeleteEventSingleCommandInEventManager()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            CalendarEvent     calendarEvent = new CalendarEvent();

            calendarEvent.Title = "Party";
            eventsManager.AddEvent(calendarEvent);

            Assert.AreEqual(eventsManager.CurrentEventsCount, 1);

            eventsManager.DeleteEventsByTitle("Party");
            Assert.AreEqual(eventsManager.CurrentEventsCount, 0);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
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());
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public void TestDeleteEventsByTitle_WhenMultipleEventsAreAddedAndNoneOfThemMatch()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            int totalNumberOfEvents         = 10;

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

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

            Assert.AreEqual(0, numberOfDeletedEvents);
        }
Exemplo n.º 14
0
        public void TestDeleteEventsByTitle_WhenMultipleEventsAreAddedAndSomeOfThemMatch()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            int totalNumberOfEvents         = 10;

            for (int i = 0; i < totalNumberOfEvents; i++)
            {
                string titleIndex = (i % 2).ToString();
                eventsManager.AddEvent(new Event(DateTime.Now, "Title" + titleIndex));
            }

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

            Assert.AreEqual(totalNumberOfEvents / 2, numberOfDeletedEvents);
        }
        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 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 TestDeleteNoMatchingEvent()
        {
            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("Nqma me");

            Assert.AreEqual(0, deleted);
            Assert.AreEqual(3, manager.DatesList.Count);
            Assert.AreEqual(3, manager.TitlesList.Count);
        }
        public void TestDeleteNonExistingEvent()
        {
            EventsManagerFast eventManager = new EventsManagerFast();

            Event ev = new Event();

            ev.Title    = "C# course - 756828";
            ev.Date     = DateTime.ParseExact("2001-01-01T10:30:01", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev.Location = "Telerik academy";
            eventManager.AddEvent(ev);

            Event ev2 = new Event();

            ev2.Title    = "EXAM - 564705";
            ev2.Date     = DateTime.ParseExact("2001-01-01T10:30:01", "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            ev2.Location = "Sofia - 230340";
            eventManager.AddEvent(ev2);

            var deletedEventsCount = eventManager.DeleteEventsByTitle("Non existing event");

            Assert.AreEqual(0, deletedEventsCount);
        }
Exemplo n.º 19
0
        public void DeleteEventNoMatchingEvents()
        {
            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 date2 = DateTime.ParseExact("2012-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     = date1,
                Title    = "1party Lora1",
                Location = null,
            };


            var calendarEvent3 = new CalendarEvent
            {
                Date     = date2,
                Title    = "2party Lora2",
                Location = "Sofia",
            };

            EventsManagerFast eventsManager = new EventsManagerFast();

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

            eventsManager.DeleteEventsByTitle("SomeTitle");

            Assert.AreEqual(eventsManager.CurrentEventsCount, 3);
        }
        public void TestDeleteMultipleEventsWithSameTitle()
        {
            EventsManagerFast eventManager = new EventsManagerFast();

            Event ev = new Event();

            ev.Title    = "C# course - 756828";
            ev.Date     = DateTime.ParseExact("2001-01-01T10:30:01", "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("2001-01-01T10:30:01", "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("2001-01-01T10:30:01", "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);

            var deletedEventsCount = eventManager.DeleteEventsByTitle("C# course - 756828");

            Assert.AreEqual(2, deletedEventsCount);
            Assert.AreEqual(1, eventManager.EventsByDateCount);
            Assert.AreEqual(2, eventManager.EventsByTitleCount);
        }
        public void TestMethodDeleteByTitleEventWithNoTitle()
        {
            EventsManagerFast eventManagerFast = new EventsManagerFast();
            Event ev = new Event();
            ev.DateTime = DateTime.Parse("2012-01-21T20:00:00");
            ev.Location = "home";
            if (ev.Title != null)
            {
                eventManagerFast.AddEvent(ev);
                eventManagerFast.DeleteEventsByTitle(ev.Title);
            }

            Assert.AreEqual(0, eventManagerFast.Count);
        }
        public void DeleteOneEventTest()
        {
            var eventManager = new EventsManagerFast();

            string[] eventParameters = { "2010-01-01T00:00:00", "party Viki 2010" };
            var command = new Command { CommandName = "DeleteEvents", 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);

            string expected;
            string actual;

            int numberOfDeletedEvents = eventManager.DeleteEventsByTitle("party Viki 2010");
            expected = "1 events deleted";

            if (numberOfDeletedEvents == 0)
            {
                actual = "No events found";
            }
            else
	        {
                actual = numberOfDeletedEvents + " events deleted";
	        }

            Assert.AreEqual(expected, actual);
        }
        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);
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
        public void DeleteEventsWithNullTitle()
        {
            IEventsManager eventsManager = new EventsManagerFast();

            eventsManager.DeleteEventsByTitle(null);
        }
Exemplo n.º 26
0
        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 TestMethodDeleteDuplicatedEventsByTitle()
        {
            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 = "party Viki";
            secondEvent.DateTime = DateTime.Parse("2012-01-21T20:00:00");
            secondEvent.Location = "home";
            eventManagerFast.AddEvent(firstEvent);
            eventManagerFast.AddEvent(secondEvent);
            eventManagerFast.DeleteEventsByTitle(firstEvent.Title);

            Assert.AreEqual(0, eventManagerFast.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 TestMethodDeleteSingleEventByTitle()
        {
            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);
            eventManagerFast.DeleteEventsByTitle(ev.Title);

            Assert.AreEqual(0, eventManagerFast.Count);
        }