public void NotAuthenticationSessionTest() { var userId = Guid.NewGuid(); var session = new Session(userId); List <Session> sessions = new List <Session>(); sessions.Add(session); var mock = new Mock <IUnitOfWork>(MockBehavior.Strict); mock.Setup(m => m.SessionRepository.Create(It.IsAny <Session>())); mock.Setup(m => m.SessionRepository.Save()); mock.Setup(m => m.SessionRepository.Get(null, null, null)).Returns(sessions); var sessionLogic = new ST.BusinessLogic.SessionService(mock.Object); sessionLogic.Create(userId); sessionLogic.IsAuthentication(Guid.NewGuid()); mock.VerifyAll(); }
public void GetTokenSessionTest() { var userId = Guid.NewGuid(); var session = new Session(userId); List <Session> sessions = new List <Session>(); sessions.Add(session); var mock = new Mock <IUnitOfWork>(MockBehavior.Strict); mock.Setup(m => m.SessionRepository.Create(It.IsAny <Session>())); mock.Setup(m => m.SessionRepository.Save()); mock.Setup(m => m.SessionRepository.Get(null, null, null)).Returns(sessions); var sessionLogic = new ST.BusinessLogic.SessionService(mock.Object); sessionLogic.Create(userId); var result = ((List <Session>)sessionLogic.GetAll()).First(); mock.VerifyAll(); Assert.AreEqual(session.Token, result.Token); }