Esempio n. 1
0
        public void TestSimpleAddRemoveSession()
        {
            var mock = new Mock<ISessionRepository>();
              var manager = new SessionManager(mock.Object);

              Session newSession = new SessionBuilder().StartDefault().Build();
              manager.AddSession(newSession);

              Assert.AreEqual(1, manager.GetSessions().Count());
              Assert.AreSame(newSession, manager.GetSessions().First());

              manager.RemoveSession(newSession);

              Assert.AreEqual(0, manager.GetSessions().Count());
        }
Esempio n. 2
0
        public void TestLoad()
        {
            Session s1 = new SessionBuilder().StartDefault("S1").Build();
              Session s2 = new SessionBuilder().StartDefault("S2").Build();
              Session s3 = new SessionBuilder().StartDefault("S3").Build();

              var mock = new Mock<ISessionRepository>();
              mock.Setup(repo => repo.GetAllSessions()).Returns(new List<Session>() { s1, s2, s3 });
              mock.Setup(repo => repo.GetCurrentSessionName()).Returns("S2");

              var manager = new SessionManager(mock.Object);

              manager.Load();

              var sessions = manager.GetSessions();

              Assert.AreEqual(3, sessions.Count());

              Assert.AreEqual(1, sessions.Where(s => s.Equals(s1)).Count());
              Assert.AreEqual(1, sessions.Where(s => s.Equals(s2)).Count());
              Assert.AreEqual(1, sessions.Where(s => s.Equals(s3)).Count());

              Assert.AreSame(s2, manager.CurrentSession);
        }