public void Delete_IdExists_ReturnsTrue() { // Arrange TodoItem outResult; A.CallTo(() => _repository.RemoveItem(A <Guid> ._, out outResult)).Returns(true); // Act var result = _todoService.Delete(_todoItem.Id); // Assert result.IsSuccess.Should().BeTrue(); result.IsNotFoundError.Should().BeFalse(); }
void Edit_Click(object sender, RoutedEventArgs e) { Analytics.TrackEvent("Action From Context Menu"); var btn = sender as Button; var todo = btn.Tag as Todo; switch (btn.Name) { case "delete": _service.Delete(todo); break; case "edit": PageMaster.current.TimeLine.Navigate(typeof(Views.SubMaster.Add.Task), todo); break; case "Done": _service.Done(todo); break; case "Undo": _service.Undone(todo); break; case "Postpone": _service.Postpone(todo); break; default: break; } }
public void CanDeleteTodo() { // setup var options = new DbContextOptionsBuilder <TodoContext>() .UseInMemoryDatabase(databaseName: "TodoDb5") .Options; using (var context = new TodoContext(options)) { context.Todos.Add(new Todo { Title = "Test Todo 1", Description = "Description Todo 1" }); context.Todos.Add(new Todo { Title = "Test Todo 2", Description = "Description Todo 2" }); context.Todos.Add(new Todo { Title = "Test Todo 3", Description = "Description Todo 3" }); context.Todos.Add(new Todo { Title = "Test Todo 4", Description = "Description Todo 4" }); context.Todos.Add(new Todo { Title = "Test Todo 5", Description = "Description Todo 5" }); context.SaveChanges(); } // operation var todoService = new TodoService(new TodoContext(options)); var result = todoService.Delete(1); // assert Assert.AreEqual(1, result.Id); }
public void Delete_Todo_Id1() { var teste = new TodoService(mockTodoRepository.Object); var retorno = teste.Delete(1); Assert.IsTrue(retorno); }
void Edit_Click(object sender, RoutedEventArgs e) { Analytics.TrackEvent("Action From Context Menu"); var btn = sender as Button; var todo = btn.Tag as Todo; switch (btn.Name) { case "delete": TodoService.Delete(todo); break; case "edit": // Edit page navigation break; case "Done": TodoService.Done(todo); break; case "Undo": TodoService.Undone(todo); break; case "Postpone": TodoService.Postpone(todo); break; default: break; } }
public async Task <IActionResult> DeleteTodo(int Id) { if (Id != 0) { return(Ok(await _todoService.Delete(Id).ConfigureAwait(false))); } return(BadRequest()); }
public IActionResult Delete(string id) { if (_todo.Get(id) == null) { return(NotFound()); } _todo.Delete(id); return(new OkResult()); }
public void Delete() { var mockDb = new Mock <IDatabase>(); var service = new TodoService(mockDb.Object); service.Delete(EXISTING_ID); mockDb.Verify(db => db.Delete(EXISTING_ID)); }
public async Task <ActionResult <object> > Delete([FromQuery] Guid id) { try { return(await _todoService.Delete(id)); } catch (Exception ex) { return(new ApiResponse(ex.Message)); } }
public ActionResult DeleteTas(string id) { var item = _todoService.GetById(id); if (item == null) { return(NotFound()); } _todoService.Delete(item); return(Ok()); }
public IActionResult Delete(int id) { if (!ModelState.IsValid) { return(View(id)); } // Add customer to DB service.Delete(id); // Redirect to index return(RedirectToAction("Create")); }
public void RemovesItem() { var todoItem = _service.Add(new TodoItem() { Name = "item0" }); _service.Delete(todoItem.Id); var result = _service.GetById(todoItem.Id); Assert.Null(result); }
public async Task <HttpResponseMessage> DeleteTodo(int id) { var todo = await _todosService.Get(id); if (todo != null) { await _todosService.Delete(id); return(new HttpResponseMessage(HttpStatusCode.NoContent)); } return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorDtoResponse("Todo not Found"), GlobalConfiguration.Configuration.Formatters.JsonFormatter)); }
public ApiResponse Delete(int id) { var response = new ApiResponse(); try { response.Data = _todoService.Delete(id); } catch (Exception ex) { response.HasError = true; response.ErrorMessage = ex.Message; } response.ResponseDate = DateTime.Now; return(response); }
public async void CanCreateTodo() { using (var context = CreateContext()) { var todoService = new TodoService(context); var user = new User() { Email = "*****@*****.**", PasswordHash = "!@#QWE" }; var todoItem = await todoService.Create("Test", "Test", user); Assert.NotNull(todoItem); Assert.True(todoItem.Id > 0); await todoService.Delete(todoItem.Id); } }
public void DeleteTodo() { var options = new DbContextOptionsBuilder <TodoContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; using (var context = new TodoContext(options)) { var service = new TodoService(context); TodoItem item = new TodoItem(); item.Name = "Go to store"; item.Id = 1; item.IsComplete = false; service.Create(item); service.Delete(1); Assert.Equal(0, context.TodoItems.ToList().Count); } }
public async Task <IActionResult> DeleteTodo(int id) { var todoFromDb = await _todosService.GetById(id); if (todoFromDb == null) { return(new NotFoundObjectResult(Json(new { Success = false, FullMessages = new[] { "Not Found" } }))); } _todosService.Delete(id); return(NoContent()); }
public IHttpActionResult Delete([FromBody] ContentDto item) { _todoService.Delete(item.Value); return(Ok()); }
public void TodoService_Should_CRUD() { var userId = Guid.NewGuid(); var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new MappingDTOProfile()); }); var mapper = mockMapper.CreateMapper(); using (var context = new ApplicationDbContext(options)) { var service = new TodoService(context, mapper); Assert.Equal(0, context.Todos.Count()); var list1 = service.List(new ListTODO() { Page = 1, PageSize = 10, UserId = userId }); Assert.Equal(0, list1.TotalItems); Assert.Equal(0, list1.Items.Count()); for (var i = 0; i < 50; i++) { var ret1 = service.Create(new CreateTODO() { Title = "item " + i, PublicId = Guid.NewGuid(), UserId = userId }); Assert.Equal(false, ret1.HasError); } Assert.Equal(50, context.Todos.Count()); var list2 = service.List(new ListTODO() { Page = 1, PageSize = 10, UserId = userId }); Assert.Equal(50, list2.TotalItems); Assert.Equal(10, list2.Items.Count()); var editId = context.Todos.Skip(3).First().PublicId; var edit1 = service.Find(new FindToDoRequest() { PublicId = editId, UserId = userId }); Assert.Equal(false, edit1.HasError); Assert.NotNull(edit1.Data); var origField = edit1.Data.Title; const string newValue = "new value"; service.Update(new UpdateTODO() { Title = newValue, PublicId = editId, UserId = userId }); var edit2 = service.Find(new FindToDoRequest() { PublicId = editId, UserId = userId }); Assert.Equal(false, edit1.HasError); Assert.NotNull(edit1.Data); Assert.Equal(newValue, edit1.Data.Title); Assert.Equal(newValue, edit1.Data.Title); Assert.Equal(editId, edit1.Data.PublicId); service.Delete(new DeleteTODO() { PublicId = editId, UserId = userId }); Assert.Equal(50, context.Todos.Count()); var list3 = service.List(new ListTODO() { Page = 1, PageSize = 10, UserId = userId }); Assert.Equal(49, list3.TotalItems); var newId = Guid.NewGuid(); var cr1 = service.Create(new CreateTODO() { Title = newValue, PublicId = newId, UserId = userId }); Assert.Equal(false, cr1.HasError); Assert.NotNull(cr1.Data); Assert.Equal(newValue, cr1.Data.Title); Assert.Equal(newId, cr1.Data.PublicId); Assert.Equal(51, context.Todos.Count()); var list4 = service.List(new ListTODO() { Page = 1, PageSize = 10, UserId = userId }); Assert.Equal(50, list4.TotalItems); } // Use a separate instance of the context to verify correct data was saved to database using (var context = new ApplicationDbContext(options)) { Assert.Equal(50, context.Todos.Count(x => !x.IsDeleted)); Assert.Equal(51, context.Todos.Count()); } }
public FubuContinuation delete_todo(Delete model) { _toDoService.Delete(model.Todo); return(FubuContinuation.RedirectTo <TodoEndpoint>(endpoint => endpoint.get_list())); }
public async Task <HttpResponseMessage> DeleteTodo(int id) { await _todosService.Delete(id); return(StatusCodeAndDtoWrapper.BuildSuccess("Todo Deleted Successfully")); }
public IActionResult DeleteTodo(int id) { _todosService.Delete(id); return(StatusCodeAndDtoWrapper.BuildSuccess("Todo Deleted Successfully")); }
public IActionResult Delete(int id) { todoService.Delete(id); return(NoContent()); }
public bool Delete(int _id) { return(todoService.Delete(_id)); }
public ActionResult Delete(int id) { _service.Delete(id); return(Ok()); }
public ActionResult Delete(int id) { service.Delete(id); return(RedirectToAction("Index")); }
public async Task <bool> Handle(DeleteTodoCommand request, CancellationToken cancellationToken) { await _todoService.Delete(request.Id); return(true); }