public void Read_Return_OkResult() { //Arrange var controller = new TodosController(_todoItemService, null, null); //Act var data = controller.Read(); //Assert Assert.IsType <OkObjectResult>(data); }
public void ReadById_Return_BadRequestResult() { //Arrange var controller = new TodosController(_todoItemService, null, null); var id = Guid.Empty; //Act var data = controller.Read(id); //Assert Assert.IsType <BadRequestObjectResult>(data); }
public void ReadById_Return_OkResult() { //Arrange var controller = new TodosController(_todoItemService, null, null); var id = TestHelper.TodoItems.ElementAt(0).Id; //Act var data = controller.Read(id); //Assert Assert.IsType <OkObjectResult>(data); }
public void Update_ValidData_OkResult() { //Arrange var controller = new TodosController(_todoItemService, null, null); var id = TestHelper.TodoItems.ElementAt(1).Id; //Act var existingItem = controller.Read(id); var okResult = (OkObjectResult)existingItem; var item = (TodoItem)okResult.Value; item.Name = "Updated Todo"; var updatedData = controller.Update(id, item); //Assert Assert.IsType <OkObjectResult>(updatedData); }
public void Read_CountTodos_MatchResult() { //Arrange var controller = new TodosController(_todoItemService, null, null); //Act var data = controller.Read(); //Assert Assert.IsType <OkObjectResult>(data); var okResult = (OkObjectResult)data; var queryableItems = (IQueryable <TodoItem>)okResult.Value; var itemsCount = queryableItems.AsEnumerable().Count(); //Assert Assert.Equal(4, itemsCount); }
public void ReadById_Return_MatchResult() { //Arrange var controller = new TodosController(_todoItemService, null, null); var id = TestHelper.TodoItems.ElementAt(0).Id; //Act var data = controller.Read(id); //Assert Assert.IsType <OkObjectResult>(data); var okResult = (OkObjectResult)data; var item = (TodoItem)okResult.Value; //Assert Assert.Equal("Todo 1", item.Name); Assert.Equal(Priority.IMPORTANT, item.Priority); }