Exemple #1
0
        public void delayed_message_sets_is_behind()
        {
            var oddsChange = MessageBuilder.BuildOddsChange(null, _timeProvider.Now - TimeSpan.FromSeconds(25));
            var tracker    = new TimestampTracker(PremiumCricketProducer, Interests, 20, 20);

            tracker.ProcessUserMessage(MessageInterest.AllMessages, oddsChange);
            Assert.IsTrue(tracker.IsBehind);
        }
Exemple #2
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);
        }