public async Task IndexById_ReturnsARedirectToIndexHomeWhenIdIsNull()
        {
            // Arrange
            var controller = new TemporaryController(todoItemRepository: null);

            // Act
            var result = await controller.IndexById(id : null);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Home", redirectToActionResult.ControllerName);
            Assert.Equal("Index", redirectToActionResult.ActionName);
        }
        public async Task IndexById_ReturnsContentWithTodoItemsNotFound_WhenTodoItemNotFound()
        {
            // Arrange
            int todoId   = 1;
            var mockRepo = new Mock <ITodoItemRepository>();

            mockRepo.Setup(repo => repo.GetAsync(todoId))
            .ReturnsAsync((TodoItem)null);
            var controller = new TemporaryController(mockRepo.Object);

            // Act
            var result = await controller.IndexById(todoId);

            // Assert
            var contentResult = Assert.IsType <ContentResult>(result);

            Assert.Equal("Todo items not found", contentResult.Content);
        }
        public async Task IndexById_ReturnsViewResult_WithTodoItemsVideModel()
        {
            // Arrange
            var todoId   = 1;
            var mockRepo = new Mock <ITodoItemRepository>();

            mockRepo.Setup(repo => repo.GetAsync(todoId))
            .ReturnsAsync(FakeDatasHelper.GetTestTodos().FirstOrDefault(t => t.ID == todoId));
            var controller = new TemporaryController(mockRepo.Object);

            // Act
            var result = await controller.IndexById(todoId);

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsType <List <TodoItemViewModel> >(viewResult.ViewData.Model);

            Assert.False(model[0].IsComplete);
            Assert.Equal("测试1", model[0].Name);
            Assert.Equal(DateTimeOffset.Now.Day, model[0].ModifyTime.Day);
            Assert.Equal(todoId, model[0].Id);
            Assert.Equal(2, model[0].StepCount);
        }