Beispiel #1
0
        public void ShouldDisplayAllEvents()
        {
            Events newEvent = new Events();

            string expectedConsole;
            var consoleOut = new StringWriter();

            string date = "2015/12/25";
            string title = "Christmas Day!";
            string description = "Santa Claus is comming in our house....";

            newEvent.EventsList.ShouldBeEmpty();
            newEvent.Add(date, title, description);

            string date1 = "2015/10/25";
            string title1 = "Johana's Birtday!";
            string description1 = "Don't forget to call her...";
            newEvent.Add(date1, title1, description1);

            expectedConsole = " \nDate:" + Convert.ToDateTime(date1).ToString("yyyy/MM/dd") + " \nTitle:" + title1 + " \nDescription:" + description1 + "\n" +
                " \nDate:" + Convert.ToDateTime(date).ToString("yyyy/MM/dd") + " \nTitle:" + title + " \nDescription:" + description;

            Console.SetOut(consoleOut);
            IOConsole newObj = new IOConsole(newEvent);
            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #2
0
        public void ShouldDisplayEventsBeetwenTwoDate()
        {
            IOConsole toDisplay = new IOConsole();

            string expectedConsole;
            var consoleOut = new StringWriter();

            Events newEvents = new Events {
                { new Event ( "2015/01/01", "one", "test") },
                {new Event("2015/11/15", "two") },
                { new Event("2015/07/01", "three") },
                { new Event("2015/12/03", "four", "test1") },
                { new Event("2015/03/04", "five", "test2") },
                { new Event("2015/09/08", "six") }
            };

               SetExpectedResultToConsole("2015/09/08", "six", out expectedConsole, out consoleOut);

            DateFilter firstFilter = new DateFilter( "<", "2015/10/25");
            Events firstFilteredList = firstFilter.ApplyFilter((newEvents));
            DateFilter eventsToDisplay = new DateFilter( ">", "2015/02/25");
            Events filteredList = eventsToDisplay.ApplyFilter(firstFilteredList);

            IOConsole newObj = new IOConsole(filteredList);
            newObj.DisplayEventsToConsole();
            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #3
0
        public void ShouldDisplayAllEvents()
        {
            Events newEvent = new Events();

            string expectedConsole;
            var    consoleOut = new StringWriter();

            string date        = "2015/12/25";
            string title       = "Christmas Day!";
            string description = "Santa Claus is comming in our house....";

            newEvent.EventsList.ShouldBeEmpty();
            newEvent.Add(date, title, description);

            string date1        = "2015/10/25";
            string title1       = "Johana's Birtday!";
            string description1 = "Don't forget to call her...";

            newEvent.Add(date1, title1, description1);

            expectedConsole = " \nDate:" + Convert.ToDateTime(date1).ToString("yyyy/MM/dd") + " \nTitle:" + title1 + " \nDescription:" + description1 + "\n" +
                              " \nDate:" + Convert.ToDateTime(date).ToString("yyyy/MM/dd") + " \nTitle:" + title + " \nDescription:" + description;


            Console.SetOut(consoleOut);
            IOConsole newObj = new IOConsole(newEvent);

            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #4
0
        public void ShouldDisplayEventsBeetwenTwoDate()
        {
            IOConsole toDisplay = new IOConsole();

            string expectedConsole;
            var    consoleOut = new StringWriter();

            Events newEvents = new Events {
                { new Event("2015/01/01", "one", "test") },
                { new Event("2015/11/15", "two") },
                { new Event("2015/07/01", "three") },
                { new Event("2015/12/03", "four", "test1") },
                { new Event("2015/03/04", "five", "test2") },
                { new Event("2015/09/08", "six") }
            };

            SetExpectedResultToConsole("2015/09/08", "six", out expectedConsole, out consoleOut);

            DateFilter firstFilter       = new DateFilter("<", "2015/10/25");
            Events     firstFilteredList = firstFilter.ApplyFilter((newEvents));
            DateFilter eventsToDisplay   = new DateFilter(">", "2015/02/25");
            Events     filteredList      = eventsToDisplay.ApplyFilter(firstFilteredList);

            IOConsole newObj = new IOConsole(filteredList);

            newObj.DisplayEventsToConsole();
            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #5
0
        public void ShouldDisplayEventsFromCertainDate()
        {
            Events    newEvents = new Events();
            IOConsole toDisplay = new IOConsole();

            string expectedConsole;
            var    consoleOut = new StringWriter();

            string date        = "2019/12/25";
            string title       = "Christmas Day!";
            string description = "Santa Claus is comming in our house....";

            string date1        = "2015/10/25";
            string title1       = "Johana's Birtday!";
            string description1 = "Don't forget to call her...";

            SetExpectedResultToConsole(date1, title1, out expectedConsole, out consoleOut, description1);

            newEvents.EventsList.ShouldBeEmpty();
            newEvents.Add(date, title, description);
            newEvents.Add(date1, title1, description1);

            DateFilter eventsToDisplay = new DateFilter("=", "2015/10/25");
            Events     filteredList    = eventsToDisplay.ApplyFilter(newEvents);

            IOConsole newObj = new IOConsole(filteredList);

            newObj.DisplayEventsToConsole();
            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #6
0
        public void ShouldNotDisplayEventsForEmptyCalendar()
        {
            Events newEvent = new Events();

            newEvent.EventsList.ShouldBeEmpty();

            string expectedConsole = "";

            var consoleOut = new StringWriter();

            Console.SetOut(consoleOut);

            IOConsole newObj = new IOConsole(newEvent);

            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #7
0
        public static void DisplayEvents(string parameter)
        {
            TXTFile files = new TXTFile();
            Events eventsList = files.LoadEventsFromFile();
            IOConsole display = new IOConsole(eventsList);

            if (parameter == "all")
            {
                display.DisplayEventsToConsole();
            }
            else
            {
                string criteria = Utils.ParseFilteringCriteria(parameter);
                Events eventsToDisplay = SimpleDateFiltering(eventsList, criteria, DateTime.Today.ToShortDateString());
                IOConsole toDisplay = new IOConsole(eventsToDisplay);
                toDisplay.DisplayEventsToConsole();
            }
        }
Beispiel #8
0
        public void ShouldDisplayOneEventWithoutDescription()
        {
            Events       newEvent = new Events();
            string       expectedConsole;
            StringWriter consoleOut;

            string date  = "2015/12/25";
            string title = "Christmas Day!";

            SetExpectedResultToConsole(date, title, out expectedConsole, out consoleOut);

            newEvent.EventsList.ShouldBeEmpty();
            newEvent.Add(date, title);

            IOConsole newObj = new IOConsole(newEvent);

            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #9
0
        public void ShouldDisplayMulytiLineOneEvent()
        {
            Events       newEvent = new Events();
            string       expectedConsole;
            StringWriter consoleOut;

            string date        = "2015/12/25";
            string title       = "Christmas \n Day!";
            string description = "Santa Claus is comming in our house....\n";

            SetExpectedResultToConsole(date, title, out expectedConsole, out consoleOut, description);

            newEvent.EventsList.ShouldBeEmpty();
            newEvent.Add(date, title, description);

            IOConsole newObj = new IOConsole(newEvent);

            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #10
0
        public void ShouldDisplayEventsFromCertainDate()
        {
            Events newEvents = new Events();
            IOConsole toDisplay = new IOConsole();

            string expectedConsole;
            var consoleOut = new StringWriter();

            string date = "2019/12/25";
            string title = "Christmas Day!";
            string description = "Santa Claus is comming in our house....";

            string date1 = "2015/10/25";
            string title1 = "Johana's Birtday!";
            string description1 = "Don't forget to call her...";

            SetExpectedResultToConsole(date1, title1,out expectedConsole, out consoleOut, description1);

            newEvents.EventsList.ShouldBeEmpty();
            newEvents.Add(date, title, description);
            newEvents.Add(date1, title1, description1);

            DateFilter eventsToDisplay = new DateFilter("=", "2015/10/25");
            Events filteredList = eventsToDisplay.ApplyFilter(newEvents);

            IOConsole newObj = new IOConsole(filteredList);
            newObj.DisplayEventsToConsole();
            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #11
0
        public void ShouldNotDisplayEventsForEmptyCalendar()
        {
            Events newEvent = new Events();

            newEvent.EventsList.ShouldBeEmpty();

            string expectedConsole = "";

            var consoleOut = new StringWriter();
            Console.SetOut(consoleOut);

            IOConsole newObj = new IOConsole(newEvent);
            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #12
0
        public void ShouldDisplayOneEventWithoutDescription()
        {
            Events newEvent = new Events();
            string expectedConsole;
            StringWriter consoleOut;

            string date = "2015/12/25";
            string title = "Christmas Day!";
            SetExpectedResultToConsole(date, title, out expectedConsole, out consoleOut);

            newEvent.EventsList.ShouldBeEmpty();
            newEvent.Add(date, title);

            IOConsole newObj = new IOConsole(newEvent);
            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #13
0
        public void ShouldDisplayOneEvent()
        {
            Events newEvent = new Events();
            string expectedConsole;
            StringWriter consoleOut;

            string date = "2015/12/25";
            string title = "Santa Claus";
            string description = "Santa Claus is comming in our house....";
            SetExpectedResultToConsole(date, title,out expectedConsole, out consoleOut,description);

            newEvent.EventsList.ShouldBeEmpty();
            newEvent.Add(date, title,description);

            IOConsole newObj = new IOConsole(newEvent);
            newObj.DisplayEventsToConsole();

            consoleOut.ToString().ShouldContain(expectedConsole);
        }
Beispiel #14
0
        public static Events SearchEvents(Events eventsList, string field, string op, string[] values)
        {
            Events filteredList = FilterEvents(eventsList, field, op, values);

            IOConsole toDisplay = new IOConsole(filteredList);
            toDisplay.DisplayEventsToConsole();
            return filteredList;
        }