示例#1
0
            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));
     }
 }
示例#4
0
 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()));
 }
示例#5
0
 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));
     }
 }
示例#6
0
            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);
            }
示例#7
0
        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")));
            }
        }
示例#8
0
        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!");
        }
示例#9
0
 private static void Delete()
 {
     var person = FindPerson();
     if (person != null)
         PeopleService.Delete(person.Id);
 }