Exemple #1
0
        public void TestPrintMultipleTodo()
        {
            Todo todo = new Todo();

            todo.Initialize("Erlend");
            todo.AddTodo("Something");
            todo.AddTodo("Something else");

            string expected = "#1 Something\r\n#2 Something else";

            var currentConsoleOut = Console.Out;

            using (var output = new ConsoleOutput())
            {
                todo.PrintTodo();
                Assert.AreEqual(expected, output.GetOutput());
            }
            Assert.AreEqual(currentConsoleOut, Console.Out);
        }
Exemple #2
0
        public void TestIdCounter()
        {
            Todo todo = new Todo();

            todo.Initialize("Erlend");
            todo.AddTodo("1");
            todo.AddTodo("2");
            todo.RemoveTodo("#1");
            todo.AddTodo("3");

            string expected = "#2 2\r\n#3 3";

            var currentConsoleOut = Console.Out;

            using (var output = new ConsoleOutput())
            {
                todo.PrintTodo();
                Assert.AreEqual(expected, output.GetOutput());
            }
            Assert.AreEqual(currentConsoleOut, Console.Out);
        }
Exemple #3
0
        public void TestAddTodo()
        {
            Todo todo = new Todo();

            todo.Initialize("Erlend");
            string expected = "Added new task: #1 Make unit test";

            var currentConsoleOut = Console.Out;

            using (var output = new ConsoleOutput())
            {
                todo.AddTodo("Make unit test");
                Assert.AreEqual(expected, output.GetOutput());
            }
            Assert.AreEqual(currentConsoleOut, Console.Out);
        }
Exemple #4
0
        public void TestDoTodo()
        {
            Todo todo = new Todo();

            todo.Initialize("Erlend");
            todo.AddTodo("Something");
            string expected = "Task #1 done!";

            var currentConsoleOut = Console.Out;

            using (var output = new ConsoleOutput())
            {
                todo.RemoveTodo("#1");
                Assert.AreEqual(expected, output.GetOutput());
            }
            Assert.AreEqual(currentConsoleOut, Console.Out);
        }
Exemple #5
0
        public void TestDoubleDigitIdPrintSort()
        {
            Todo todo = new Todo();

            todo.Initialize("Erlend");

            for (int i = 0; i <= 10; i++)
            {
                todo.AddTodo("x");
            }

            string expected = "#1 x\r\n#2 x\r\n#3 x\r\n#4 x\r\n#5 x\r\n#6 x\r\n#7 x\r\n#8 x\r\n#9 x\r\n#10 x\r\n#11 x";

            var currentConsoleOut = Console.Out;

            using (var output = new ConsoleOutput())
            {
                todo.PrintTodo();
                Assert.AreEqual(expected, output.GetOutput());
            }
            Assert.AreEqual(currentConsoleOut, Console.Out);
        }