public async Task Should_return_false_if_student_id_does_NOT_exist() { var suppliedContext = AsyncDatabaseContextMockingHelper.GetMockedStudentDatabaseContext(); IPeopleService service = new PeopleService(suppliedContext.Object); var actualValue = await service.Delete(-99); Assert.That(actualValue, Is.False); }
public IActionResult Delete(string id) { var person = _peopleService.Get(id); if (person == null) { return(NotFound()); } _peopleService.Delete(id); return(NoContent()); }
public HttpResponseMessage Delete(int id) { try { svc.Delete(id); SuccessResponse response = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage Delete(int id) { try { PeopleService svc = new PeopleService(); svc.Delete(id); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, new SuccessResponse())); }
public HttpResponseMessage Delete(int id) { try { PeopleService svc = new PeopleService(); svc.Delete(id); SuccessResponse resp = new SuccessResponse(); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception msg) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, msg.Message)); } }
public async Task Should_delete_student() { var suppliedStudentDbSet = AsyncDatabaseContextMockingHelper.GetStudentDbSet(); var suppliedContext = AsyncDatabaseContextMockingHelper.GetMockedStudentDatabaseContext(suppliedStudentDbSet.Object); IPeopleService service = new PeopleService(suppliedContext.Object); await service.Delete(1); var actualDeletedStudent = suppliedContext.Object.People.Single(x => x.Id == 1); // If testing for fisical delete then uncomment this line. //suppliedStudentDbSet.Verify<Person>(m => m.Remove(actualDeletedStudent), Times.Once); suppliedContext.Verify(m => m.SaveChangesAsync(), Times.Once); }
public async Task <ActionResult> Delete(Guid id) { try { await _service.Delete(id); return(StatusCode(204)); } catch (ValidationException e) { return(StatusCode(400, new ErrorDto(e.Message))); } catch (Exception) { // Erro desconhecido return(StatusCode(500, new ErrorDto("Ocorreu um erro desconhecido na operação"))); } }
public void Delete_Test() { //arrange PeopleAddRequest test = new PeopleAddRequest { FirstName = "Test", LastName = "Test", DOB = DateTime.Now, ModifiedBy = "Test" }; int deleteTest = svc.Insert(test); //act svc.Delete(deleteTest); People getDeleted = svc.GetById(deleteTest); //assert Assert.IsNull(getDeleted.FirstName, "Delete has failed!"); Assert.IsNull(getDeleted.LastName, "Delete has failed!"); Assert.IsFalse(test.DOB == getDeleted.DOB, "Delete has failed"); Assert.IsNull(getDeleted.ModifiedBy, "Delete has failed!"); }
private static void Delete() { var person = FindPerson(); if (person != null) PeopleService.Delete(person.Id); }