示例#1
0
        public void CollectStats()
        {
            var dataMock = new DataServiceMock();
            var timeMock = new MockedTimeSource();

            var authService  = new VitaAuthService(dataMock);
            var trackService = new TrackingService(timeMock);

            ITrackingReport report = null;

            trackService.Reports.Subscribe(x => report = x);

            ITrackingSession session = SessionTrackingScenarioOne(timeMock, trackService);

            trackService.PublishReports();

            Assert.IsNotNull(report);
            Assert.AreEqual(report.Topics.Count(), 3);
            Assert.IsTrue(report.Topics.All(x => x.ImpressionCount == 1));
            Assert.AreEqual(report.Topics[0].Url, "person");
            Assert.AreEqual(report.Topics[0].TopicDetail, "S");
            Assert.AreEqual(report.Topics[0].ImpressionTimeSpan, TimeSpan.FromSeconds(20 + 12 + 0));
            Assert.AreEqual(report.Topics[1].ImpressionTimeSpan, TimeSpan.FromSeconds(20 + 60 + 60));
            Assert.AreEqual(report.Topics[2].ImpressionTimeSpan, TimeSpan.FromSeconds(2 + 18 + 42));
        }
示例#2
0
        private void timerSession_Tick(object sender, EventArgs e)
        {
            ITrackingSession session = _timeTracking.CurrentSession;

            lblSessionStart.Text = $"Started: {session.Start.ToString("HH:mm:ss")}";
            TimeSpan duration = DateTime.Now - session.Start;

            lblSessionDuration.Text = $"Duration: {duration.Hours.ToString("00")}:{duration.Minutes.ToString("00")}:{duration.Seconds.ToString("00")}";
        }
示例#3
0
        public void AddSession(ITrackingSession session)
        {
            if (!session.End.HasValue)
            {
                session.End = DateTime.Now;
            }

            var sessions = new List <ITrackingSession>(_sessionStore.Read <TrackingSession>());

            sessions.Add(session);
            _sessionStore.Write(sessions);
        }