コード例 #1
0
 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);
 }
コード例 #2
0
        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));
            }
        }