コード例 #1
0
        public void ShouldAddSingleItem()
        {
            var      id   = 0;
            TodoItem item = new TodoItem()
            {
                ItemType  = TodoItemType.Single,
                Title     = "Single item",
                Completed = false
            };
            TodoList itemList = new TodoList();

            itemList.Tasks.Add(item);

            TodoRepository repository = new TodoRepository();

            repository.AddTodos(itemList);

            var output = repository.DisplayAllItems();

            Assert.That(output, Is.EqualTo($"[ ] ({id}) {item.Title}\n"));
        }
コード例 #2
0
        public async Task Run()
        {
            var repository = new TodoRepository();
            var todoList   = new TodoList();
            var askForTodo = true;

            while (askForTodo)
            {
                if (ShouldCreateList())
                {
                    int subitemsAmount = 0;
                    var todo           = new TodoItem()
                    {
                        Title = ProvideTitle(),
                    };
                    subitemsAmount = ProvideAmount();
                    todo.Items     = CreateListOfItems(subitemsAmount);
                    todoList.Tasks.Add(todo);
                }
                else
                {
                    TodoItem todo = new TodoItem()
                    {
                        Title = ProvideTitle()
                    };
                    todoList.Tasks.Add(todo);
                }

                askForTodo = AskForRestart();
            }
            await repository.LoadItems(Path);

            repository.AddTodos(todoList);
            repository.DisplayAllItems();
            await repository.SaveItems(Path);
        }