Example #1
0
        public void VerifySessionChangesOnDisableThenEnable()
        {
            // Do a first session.
            Log actualLog = null;

            _mockChannel.Setup(channel => channel.EnqueueAsync(It.IsAny <StartSessionLog>())).Callback <Log>(log => actualLog = log);
            _sessionTracker.Resume();
            _mockChannel.Verify(channel => channel.EnqueueAsync(It.IsNotNull <StartSessionLog>()), Times.Once());
            var firstLog = actualLog;

            Assert.IsNotNull(actualLog.Sid);
            Assert.AreEqual(SessionContext.SessionId, actualLog.Sid);

            // Disable.
            _sessionTracker.Stop();
            Assert.IsNull(SessionContext.SessionId);

            // Re-enable.
            _sessionTracker = new SessionTracker(_mockChannelGroup.Object, _mockChannel.Object);
            _sessionTracker.Resume();

            // Verify second session has a different identifier, not the new one Analytics wanted but the updated correlation identifier instead.
            _mockChannel.Verify(channel => channel.EnqueueAsync(It.IsNotNull <StartSessionLog>()), Times.Exactly(2));
            var secondLog = actualLog;

            Assert.IsNotNull(secondLog.Sid);
            Assert.AreNotEqual(firstLog.Sid, secondLog.Sid);
        }
Example #2
0
        public void VerifySessionChangesOnReenabling()
        {
            _sessionTracker.Resume();
            var sid1 = SessionTracker.Sid;

            Assert.AreNotEqual(Guid.Empty, sid1);

            // Disable and enable again.
            _sessionTracker = new SessionTracker(_mockChannelGroup.Object, _mockChannel.Object);
            _sessionTracker.Resume();

            // Verify second session has a different identifier, not the new one analytics wanted but the updated correlation identifier instead.
            var sid2 = SessionTracker.Sid;

            Assert.AreNotEqual(Guid.Empty, sid2);
            Assert.AreNotEqual(sid1, sid2);
        }
Example #3
0
        public void ResumeFirstTime()
        {
            _sessionTracker.Resume();

            _mockChannel.Verify(channel => channel.EnqueueAsync(It.IsAny <StartSessionLog>()), Times.Once());
        }
Example #4
0
        public void ResumeFirstTime()
        {
            Log actualLog = null;

            _mockChannel.Setup(channel => channel.EnqueueAsync(It.IsAny <StartSessionLog>())).Callback <Log>(log => actualLog = log);
            _sessionTracker.Resume();
            _mockChannel.Verify(channel => channel.EnqueueAsync(It.IsNotNull <StartSessionLog>()), Times.Once());
            Assert.IsNotNull(actualLog.Sid);
        }