Beispiel #1
0
        public void behaves_correctly_when_in_not_started_state()
        {
            _producerRecoveryManager.CheckStatus();
            Assert.AreEqual(_producerRecoveryManager.Status, ProducerRecoveryStatus.NotStarted);
            _producerRecoveryManager.ProcessUserMessage(_messageBuilder.BuildAlive(), MessageInterest.AllMessages);
            Assert.AreEqual(ProducerRecoveryStatus.NotStarted, _producerRecoveryManager.Status);
            _producerRecoveryManager.ProcessUserMessage(_messageBuilder.BuildBetStop(), DefaultInterest);
            Assert.AreEqual(ProducerRecoveryStatus.NotStarted, _producerRecoveryManager.Status);
            _producerRecoveryManager.ProcessUserMessage(_messageBuilder.BuildOddsChange(), DefaultInterest);
            Assert.AreEqual(ProducerRecoveryStatus.NotStarted, _producerRecoveryManager.Status);
            _producerRecoveryManager.ProcessUserMessage(_messageBuilder.BuildSnapshotComplete(1), DefaultInterest);
            Assert.AreEqual(ProducerRecoveryStatus.NotStarted, _producerRecoveryManager.Status);
            _producerRecoveryManager.ProcessSystemMessage(_messageBuilder.BuildAlive());
            Assert.AreEqual(ProducerRecoveryStatus.Started, _producerRecoveryManager.Status);
            _timeProvider.AddSeconds(30);
            _producerRecoveryManager.CheckStatus();
            Assert.AreEqual(ProducerRecoveryStatus.Started, _producerRecoveryManager.Status);

            //get everything to default state
            CreateTestInstances();
            // alive from wrong producer does nothing ...
            _producerRecoveryManager.ProcessSystemMessage(_messageBuilder.BuildAlive(5));
            Assert.AreEqual(ProducerRecoveryStatus.NotStarted, _producerRecoveryManager.Status);
            // non-subscribed alive changes state
            _producerRecoveryManager.ProcessSystemMessage(_messageBuilder.BuildAlive(null, null, false));
            Assert.AreEqual(ProducerRecoveryStatus.Started, _producerRecoveryManager.Status);
        }
Beispiel #2
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);
        }