public void ListEventsTest()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();

            string dateInput = "2000-11-13T00:00:01";

            for (int i = 0; i < 10; i++)
            {
                DateTime date = CreateDate(dateInput);
                Event testEvent = new Event(date, i.ToString());
                eventsManager.AddEvent(testEvent);
            }

            DateTime dateCheck = CreateDate(dateInput);
            int eventsCount = 10;
            IEnumerable<Event> events = eventsManager.ListEvents(dateCheck, eventsCount);
            int target = 0;
            foreach (var ev in events)
            {
                target += 1;
                Assert.AreEqual<DateTime>(ev.Date, dateCheck);
            }

            Assert.IsTrue(target == eventsCount);
        }
예제 #2
0
        public static void Main()
        {
            ////IEventsManager eventsManager = new EventsManager();
            IEventsManager eventsManager = new EventsManagerFast();
            EventProcessor eventProcessor = new EventProcessor(eventsManager);
            StringBuilder commandsResult = new StringBuilder();
            List<string> commands = new List<string>();

            while (true)
            {
                string commandInput = Console.ReadLine();

                if (string.IsNullOrEmpty(commandInput))
                {
                    throw new ArgumentException("Command can't be null or empty: " + commandInput);
                }
                else if (commandInput == "End")
                {
                    // Exit command proccessing loop and print results
                    break;
                }
                else
                {
                    commands.Add(commandInput);

                }
            }

            ProcessComands(eventProcessor, commandsResult, commands);
            Console.Write(commandsResult.ToString());
        }
        public void AddEventTest()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            DateTime date = CreateDate("2000-11-13T00:00:01");
            Event testEvent = new Event(date, "exam");
            eventsManager.AddEvent(testEvent);
            int eventsCount = eventsManager.Events.Count;
            Assert.IsTrue(eventsCount == 1);

            ICollection<Event> target = eventsManager.Events;
            Assert.IsTrue(target.Contains(testEvent));
        }
        public void DeleteEventsByTitleTest()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            DateTime date = CreateDate("2000-11-13T00:00:01");
            string title = "exam";
            Event testEvent = new Event(date, title);

            eventsManager.AddEvent(testEvent);
            eventsManager.DeleteEventsByTitle(title);

            int eventsCount = eventsManager.Events.Count;
            Assert.IsTrue(eventsCount == 0);
        }
        public void ListEventsWhenThereAreNoItemsTest()
        {
            EventsManagerFast eventsManager = new EventsManagerFast();
            string dateInput = "2000-11-13T00:00:01";
            DateTime dateCheck = CreateDate(dateInput);
            int eventsCount = 10;
            IEnumerable<Event> events = eventsManager.ListEvents(dateCheck, eventsCount);
            int target = 0;
            foreach (var ev in events)
            {
                target += 1;
            }

            Assert.IsTrue(target == 0);
        }