Ejemplo n.º 1
0
        public void violated_gives_correct_value()
        {
            var alive = new alive();

            _timeProvider.Now = DateTime.Now;
            var tracker = new TimestampTracker(PremiumCricketProducer, Interests, 20, 20);

            Assert.IsFalse(tracker.IsAliveViolated);
            _timeProvider.AddSeconds(10);
            Assert.IsFalse(tracker.IsAliveViolated);

            alive.timestamp = SdkInfo.ToEpochTime(_timeProvider.Now);
            tracker.ProcessSystemAlive(alive);
            Assert.IsFalse(tracker.IsAliveViolated);
            _timeProvider.AddSeconds(15);
            Assert.IsFalse(tracker.IsAliveViolated);
            _timeProvider.AddSeconds(10);
            Assert.IsTrue(tracker.IsAliveViolated);

            alive.timestamp = SdkInfo.ToEpochTime(_timeProvider.Now);
            tracker.ProcessSystemAlive(alive);
            Assert.IsFalse(tracker.IsAliveViolated);
            _timeProvider.AddSeconds(10);
            Assert.IsFalse(tracker.IsAliveViolated);
            _timeProvider.AddSeconds(15);
            Assert.IsTrue(tracker.IsAliveViolated);
        }
Ejemplo n.º 2
0
        public void processed_value_are_correctly_stored()
        {
            //set to some round date to avoid rounding issues
            _timeProvider.Now = new DateTime(2000, 1, 1, 1, 1, 1, 0);
            var tracker = new TimestampTracker(PremiumCricketProducer, new[] { MessageInterest.PrematchMessagesOnly, MessageInterest.LiveMessagesOnly }, 20, 20);

            tracker.ProcessSystemAlive(MessageBuilder.BuildAlive());
            _timeProvider.AddMilliSeconds(2500);

            tracker.ProcessUserMessage(MessageInterest.LiveMessagesOnly, MessageBuilder.BuildAlive());
            _timeProvider.AddMilliSeconds(1000);

            tracker.ProcessUserMessage(MessageInterest.PrematchMessagesOnly, MessageBuilder.BuildAlive());
            _timeProvider.AddMilliSeconds(1500);

            tracker.ProcessUserMessage(MessageInterest.LiveMessagesOnly, MessageBuilder.BuildBetStop(null, _timeProvider.Now - TimeSpan.FromMilliseconds(6500)));
            tracker.ProcessUserMessage(MessageInterest.PrematchMessagesOnly, MessageBuilder.BuildOddsChange(null, _timeProvider.Now - TimeSpan.FromMilliseconds(4300)));

            var trackerState = ParseLogEntry(tracker.ToString());

            Assert.IsFalse(trackerState.IsAliveViolated);
            Assert.IsFalse(trackerState.IsBehind);
            Assert.AreEqual(TimeSpan.FromMilliseconds(5000), trackerState.SystemAliveAge);
            Assert.AreEqual(TimeSpan.FromMilliseconds(2500), trackerState.Alives[MessageInterest.LiveMessagesOnly]);
            Assert.AreEqual(TimeSpan.FromMilliseconds(1500), trackerState.Alives[MessageInterest.PrematchMessagesOnly]);
            Assert.AreEqual(TimeSpan.FromMilliseconds(6500), trackerState.NonAlives[MessageInterest.LiveMessagesOnly]);
            Assert.AreEqual(TimeSpan.FromMilliseconds(4300), trackerState.NonAlives[MessageInterest.PrematchMessagesOnly]);
        }
Ejemplo n.º 3
0
        public void system_alive_resets_violation()
        {
            var tracker = new TimestampTracker(PremiumCricketProducer, Interests, 20, 20);

            _timeProvider.AddSeconds(25);
            Assert.IsTrue(tracker.IsAliveViolated);
            tracker.ProcessSystemAlive(MessageBuilder.BuildAlive());
            Assert.IsFalse(tracker.IsAliveViolated);
        }
Ejemplo n.º 4
0
        public void system_alive_timestamp_returns_correct_value()
        {
            var tracker = new TimestampTracker(PremiumCricketProducer, Interests, 20, 20);

            Assert.AreEqual(SdkInfo.ToEpochTime(_timeProvider.Now), tracker.SystemAliveTimestamp);

            _timeProvider.AddSeconds(4);
            tracker.ProcessSystemAlive(MessageBuilder.BuildAlive());
            Assert.AreEqual(SdkInfo.ToEpochTime(_timeProvider.Now), tracker.SystemAliveTimestamp);
        }