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); }
public void operation_times_out_after_allotted_time() { var operation = new RecoveryOperation(LiveProducer, _recoveryRequestIssuerMock.Object, new[] { MessageInterest.AllMessages }, 0, false); operation.Start(); _timeProvider.AddSeconds(LiveProducer.MaxRecoveryTime - 1); Assert.IsFalse(operation.HasTimedOut()); _timeProvider.AddSeconds(2); Assert.IsTrue(operation.HasTimedOut()); }
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); }
public void OperationTimesOutAfterAllottedTime() { var operation = new RecoveryOperation(_liveProducer, _recoveryRequestIssuerMock.Object, new[] { MessageInterest.AllMessages }, 0, false); operation.Start(); _timeProvider.AddSeconds(_liveProducer.MaxRecoveryTime - 1); Assert.IsFalse(operation.HasTimedOut(), $"TimeProvider={_timeProvider.Now}, StartTime={operation.LastStartTime}, MaxRecoveryTime={_liveProducer.MaxAfterAge().TotalSeconds}s"); _timeProvider.AddSeconds(2); Assert.IsTrue(operation.HasTimedOut()); }