Esempio n. 1
0
 public void DeleteUserTest()
 {
     mockUserRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(userWithAllData);
     mockUserRepo.Setup(r => r.Delete(It.IsAny <int>())).Callback <object>(x => userList.Clear());
     userBLWithoutTeamBL.Delete(userWithAllData.Id);
     mockUserRepo.Verify(x => x.GetById(It.IsAny <int>()), Times.AtLeastOnce);
     mockUserRepo.Verify(x => x.Delete(It.IsAny <int>()), Times.Once);
 }
        public ActionResult DeleteUser(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                userBusinessLogic.Delete(id);
                return(Ok(new ResponseOkDTO()));
            }
            catch (UserDoesNotExistException e)
            {
                return(NotFound(e.Message));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }