Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }