Example #1
0
        public void GetTodoListWithLimitTest()
        {
            var repo = new TodoRepository();

            repo.AddTodoList(new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            });
            repo.AddTodoList(new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            });
            repo.AddTodoList(new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            });

            var items = repo.GetTodoLists("", null, 2);

            Assert.AreEqual(2, items.Count());
        }
Example #2
0
        public void AddTaskToTodoListTest()
        {
            var repo     = new TodoRepository();
            var todoList = new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            };
            var result = repo.AddTodoList(todoList);

            Assert.IsTrue(result);
            var todoTask = new TodoTask
            {
                Id        = Guid.NewGuid().ToString(),
                Name      = "Task name",
                Completed = false
            };

            result = repo.AddTaskToTodoList(todoList.Id, todoTask);
            Assert.IsTrue(result);

            var repList = repo.FindTodoList(todoList.Id);

            Assert.IsNotNull(repList);

            var repTask = repList.Tasks.First();

            Assert.AreEqual(todoTask.Id, repTask.Id);
            Assert.AreEqual(todoTask.Name, repTask.Name);
            Assert.AreEqual(todoTask.Completed, repTask.Completed);
        }
Example #3
0
        public void CompleteTaskWithWrongTodoTaskIdTest()
        {
            var repo     = new TodoRepository();
            var todoList = new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            };

            repo.AddTodoList(todoList);
            var todoTask = new TodoTask
            {
                Id        = Guid.NewGuid().ToString(),
                Name      = "Task name",
                Completed = false
            };

            repo.AddTaskToTodoList(todoList.Id, todoTask);
            var result = repo.CompleteTask(todoList.Id, "1", true);

            Assert.IsFalse(result);

            var repList = repo.FindTodoList(todoList.Id);

            Assert.IsNotNull(repList);
            var repTask = repList.Tasks.First();

            Assert.IsFalse(repTask.Completed);
        }
Example #4
0
        public void GetTodoListsWithSearchTest()
        {
            var repo     = new TodoRepository();
            var todoList = new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            };

            repo.AddTodoList(todoList);
            repo.AddTodoList(new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "List",
                Description = "Description"
            });

            var items = repo.GetTodoLists("Name", null, null);

            Assert.AreEqual(1, items.Count());
            Assert.AreEqual(todoList.Id, items.First().Id);
        }
Example #5
0
        public void FindTodoListTest()
        {
            var repo     = new TodoRepository();
            var todoList = new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            };

            repo.AddTodoList(todoList);

            var repList = repo.FindTodoList(todoList.Id);

            Assert.IsNotNull(repList);
            Assert.AreEqual(todoList.Id, repList.Id);
        }
Example #6
0
        public void AddTaskToWrongTodoListTest()
        {
            var repo     = new TodoRepository();
            var todoList = new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            };

            repo.AddTodoList(todoList);
            var todoTask = new TodoTask
            {
                Id        = Guid.NewGuid().ToString(),
                Name      = "Task name",
                Completed = false
            };

            repo.AddTaskToTodoList("111", todoTask);
        }
Example #7
0
        public void AddDuplicateTaskToTodoListTest()
        {
            var repo     = new TodoRepository();
            var todoList = new TodoList
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Name",
                Description = "Description"
            };

            repo.AddTodoList(todoList);
            var todoTask = new TodoTask
            {
                Id        = Guid.NewGuid().ToString(),
                Name      = "Task name",
                Completed = false
            };

            repo.AddTaskToTodoList(todoList.Id, todoTask);
            var result = repo.AddTaskToTodoList(todoList.Id, todoTask);

            Assert.IsFalse(result);
        }