Пример #1
0
        public async Task DeleteToDoAsyncControllerTest()
        {
            // arrange
            var toDos = GetTestData();

            var mockToDoSet = SetupMockSetAsync(new Mock <DbSet <ToDo> >(), toDos);
            var mockContext = new Mock <AndresToDoListContext>();

            mockContext.Setup(s => s.ToDos).Returns(mockToDoSet.Object);

            var toDoToDelete = new ToDoViewModel
            {
                Id       = 1,
                ToDoItem = "Find my lost friend"
            };

            // act
            var toDoService    = new ToDoService(mockContext.Object);
            var toDoController = new ToDoController(toDoService);

            var controllerActionResult = await toDoController.DeleteToDo(toDoToDelete.Id);

            // assert
            Assert.IsInstanceOfType(controllerActionResult, typeof(OkNegotiatedContentResult <bool>));
        }
Пример #2
0
        public void Test_DeleteToDo()
        {
            MockTodoRepository mockToDoObj     = new MockTodoRepository();
            ToDoController     tc              = new ToDoController(mockToDoObj);
            TodoResponse       apiToDoResponse = tc.DeleteToDo(2);

            Assert.AreEqual(AppConstants.Success, apiToDoResponse.responseHeader.statusMessage);
            Assert.AreEqual(HttpStatusCode.OK, apiToDoResponse.responseHeader.statusCode);
        }