public void LogoutTest() { mockUserRepo.Setup(r => r.Update(It.IsAny <User>())).Callback <User>(x => userList.First().Token = null); userList.Add(adminWithAllData); userBLWithoutTeamBL.Logout(adminWithAllData.Email); mockUserRepo.Verify(x => x.Get(It.IsAny <Expression <Func <User, bool> > >(), null, ""), Times.Once); mockUserRepo.Verify(x => x.Update(It.IsAny <User>()), Times.AtLeastOnce); }
public ActionResult Logout([FromBody] LogoutDTO data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { userBusinessLogic.Logout(data.Username); return(Ok(new ResponseOkDTO())); } catch (UserDoesNotExistException e) { return(NotFound(e.Message)); } catch (UserIsNotLoggedInException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }