public void Equals_other_session_with_same_id() {
      var sessionId = new SessionId(Guid.NewGuid(), false);
      var inProcSession1 = new InProcSession(sessionId, _wrappedSession, DateTime.Now, TimeSpan.FromSeconds(3));
      var inProcSession2 = new InProcSession(sessionId, _wrappedSession, DateTime.Now, TimeSpan.FromSeconds(3));

      var actual = inProcSession1.Equals(inProcSession2);

      Assert.True(actual);
    }
    public void When_exactly_expiration_time_isexpired_returns_false() {
      var creationTime = new DateTime(2015, 10, 20, 21, 19, 0, DateTimeKind.Utc);
      var timeout = TimeSpan.FromMinutes(10.223);
      ConfigureSystemClock_ToReturn(creationTime.Add(timeout));
      var inProcSession = new InProcSession(new SessionId(Guid.NewGuid(), false), _wrappedSession, creationTime, timeout);

      var actual = inProcSession.IsExpired(_fakeSystemClock.NowUtc);

      Assert.False(actual);
    }
Example #3
0
        public void Equals_other_session_with_same_id()
        {
            var sessionId      = new SessionId(Guid.NewGuid(), false);
            var inProcSession1 = new InProcSession(sessionId, _wrappedSession, DateTime.Now, TimeSpan.FromSeconds(3));
            var inProcSession2 = new InProcSession(sessionId, _wrappedSession, DateTime.Now, TimeSpan.FromSeconds(3));

            var actual = inProcSession1.Equals(inProcSession2);

            Assert.True(actual);
        }
            public void Given_valid_session_then_caches_that_session()
            {
                var sessionId     = new SessionId(Guid.NewGuid(), true);
                var sessionToSave = new InProcSession(sessionId, _fakeSession, DateTime.Now, TimeSpan.FromMinutes(10));

                A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).Returns(sessionId);
                A.CallTo(() => _fakeSessionFactory.Create(sessionId, _fakeSession)).Returns(sessionToSave);

                _sessionManager.Save(_fakeSession, _nancyContext);
                A.CallTo(() => _fakeSessionCache.Set(sessionToSave)).MustHaveHappened();
            }
Example #5
0
        public void When_exactly_expiration_time_isexpired_returns_false()
        {
            var creationTime = new DateTime(2015, 10, 20, 21, 19, 0, DateTimeKind.Utc);
            var timeout      = TimeSpan.FromMinutes(10.223);

            ConfigureSystemClock_ToReturn(creationTime.Add(timeout));
            var inProcSession = new InProcSession(new SessionId(Guid.NewGuid(), false), _wrappedSession, creationTime, timeout);

            var actual = inProcSession.IsExpired(_fakeSystemClock.NowUtc);

            Assert.False(actual);
        }
      public void Loads_session_with_id_from_identification_method() {
        var sessionId = new SessionId(Guid.NewGuid(), false);
        var expectedSession = new InProcSession(sessionId, A.Fake<ISession>(), DateTime.Now, TimeSpan.FromMinutes(10));

        A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).Returns(sessionId);
        A.CallTo(() => _fakeSessionCache.Get(sessionId)).Returns(expectedSession);

        var actual = _sessionManager.Load(_nancyContext);

        Assert.Equal(expectedSession, actual);
        A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).MustHaveHappened();
        A.CallTo(() => _fakeSessionCache.Get(sessionId)).MustHaveHappened();
      }
            public void Loads_session_with_id_from_identification_method()
            {
                var sessionId       = new SessionId(Guid.NewGuid(), false);
                var expectedSession = new InProcSession(sessionId, A.Fake <ISession>(), DateTime.Now, TimeSpan.FromMinutes(10));

                A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).Returns(sessionId);
                A.CallTo(() => _fakeSessionCache.Get(sessionId)).Returns(expectedSession);

                var actual = _sessionManager.Load(_nancyContext);

                Assert.Equal(expectedSession, actual);
                A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).MustHaveHappened();
                A.CallTo(() => _fakeSessionCache.Get(sessionId)).MustHaveHappened();
            }
      public void Given_valid_session_then_caches_that_session() {
        var sessionId = new SessionId(Guid.NewGuid(), true);
        var sessionToSave = new InProcSession(sessionId, _fakeSession, DateTime.Now, TimeSpan.FromMinutes(10));
        A.CallTo(() => _fakeSessionIdentificationMethod.GetCurrentSessionId(_nancyContext)).Returns(sessionId);
        A.CallTo(() => _fakeSessionFactory.Create(sessionId, _fakeSession)).Returns(sessionToSave);

        _sessionManager.Save(_fakeSession, _nancyContext);
        A.CallTo(() => _fakeSessionCache.Set(sessionToSave)).MustHaveHappened();
      }