public void ShouldAddNewItemAndValidate() { // Init repository ITodoRepository repository = new TodoRepository(); // Init expected variables string expectedTitle = "Finish unit tests"; string expectedContent = "Generic description goes here"; // Set up new item var item = new TodoItem() { Title = expectedTitle, Content = expectedContent }; // Add new item to repository, fetch it by ID var newItemId = repository.AddItem(item).Id; var foundItem = repository.GetItem(newItemId); // Make assertions and check whether new item // corresponds to the found item Assert.Equal(expectedTitle, foundItem.Title); Assert.Equal(expectedContent, foundItem.Content); }
public int Post([FromBody] TodoItem newTodo) { if (newTodo != null) { // toDoItems.Add(newTodo); return(repo.AddItem(newTodo)); } // return toDoItems.IndexOf(newTodo); return(-1); }
private void AddData(DialogController dialogController) { var text = dialogController.Text; if (string.IsNullOrEmpty(text)) { return; } var item = new TodoItem { Text = text }; _repository.AddItem(item); CreateItem(item); }