public void GetActiveTodoItems()
        {
            // Arrange
            var todoItemOne = new TodoItem {
                Description = "One", Completed = true
            };
            var todoItemTwo = new TodoItem {
                Description = "One", Completed = false
            };
            var todoItemThree = new TodoItem {
                Description = "One", Completed = false
            };

            _mockTodoItemRepository
            .Setup(x => x.GetTodoItems())
            .Returns(new [] { todoItemOne, todoItemTwo, todoItemThree });

            // Act
            var result = _todoItemService.GetActiveTodoItems();

            // Assert
            Assert.Equal(2, result.Count());
            Assert.Equal(todoItemTwo, result.ElementAt(0));
            Assert.Equal(todoItemThree, result.ElementAt(1));
        }
Example #2
0
        public IActionResult ActiveItems()
        {
            try
            {
                var todoItems = _todoItemService.GetActiveTodoItems();

                return(View(MapToTodoItemModel(todoItems)));
            }
            catch
            {
                return(View(new TodoItemModel[0]));
            }
        }