public void Login_ExpectsOk() { unitOfWork.Setup(x => x.UserRepository.FirstOrDefault(It.IsAny <Expression <Func <UserEntity, bool> > >())).Returns(adminEntity); sessionRepository.Setup(u => u.Add(It.IsAny <SessionEntity>())).Verifiable(); var guid = sessionLogic.Login(adminEntity.Mail, adminEntity.Password); SessionEntity sessionEntity = new SessionEntity { Token = guid, Mail = adminEntity.Mail }; sessionRepository.Setup(x => x.FirstOrDefault(It.IsAny <Expression <Func <SessionEntity, bool> > >())).Returns(sessionEntity); var isValid = sessionLogic.IsValidToken(guid); sessionRepository.VerifyAll(); Assert.IsTrue(isValid); }