public async Task UpdateTodoItem() { //Act todoRepository.Setup(a => a.GetAllEnumerable()).Returns(todoItems.AsEnumerable <TodoItem>()); //Arrange var todoBL = new TodoBL(todoRepository.Object); TodoItemDTO item = new TodoItemDTO { Id = 2, Name = "todo22", IsComplete = true }; await todoBL.Update(2, item); TodoItem todoItem = todoItems.Where(a => a.Id == 2).First(); TodoItem temp = await todoBL.Find(2); //Assert Assert.AreEqual(temp.Name, "todo22"); }
public async Task <IActionResult> UpdateTodoItem(long id, TodoItemDTO todoItemDTO) { try { await BL.Update(id, todoItemDTO); } catch (DbUpdateConcurrencyException) when(!TodoItemExists(id)) { return(NotFound()); } catch (ArgumentException ex) { if (ex.Message == "Wrong Id") { return(BadRequest()); } else { return(NotFound()); } } return(NoContent()); }