public void Should_contain_two_messages_should_be_correlated_by_tag_and_id() { Guid timeoutId = Guid.NewGuid(); LocalBus.Publish(new ScheduleTimeout(timeoutId, 10.Seconds(), 1)); TimeoutSaga firstTimeout = _timeoutSagaRepository.ShouldContainSaga(x => x.TimeoutId == timeoutId && x.Tag == 1); firstTimeout.ShouldBeInState(TimeoutSaga.WaitingForTime); LocalBus.Publish(new CancelTimeout { CorrelationId = timeoutId, Tag = 1 }); LocalBus.Publish(new ScheduleTimeout(timeoutId, 10.Seconds(), 2)); TimeoutSaga secondTimeout = _timeoutSagaRepository.ShouldContainSaga(x => x.TimeoutId == timeoutId && x.Tag == 2); secondTimeout.ShouldBeInState(TimeoutSaga.WaitingForTime); firstTimeout.ShouldBeInState(TimeoutSaga.Completed); Trace.WriteLine("Sagas:"); foreach (TimeoutSaga saga in _timeoutSagaRepository.Where(x => true)) { Trace.WriteLine("Saga: " + saga.CorrelationId + ", TimeoutId: " + saga.TimeoutId + ", Tag: " + saga.Tag + ", State: " + saga.CurrentState.Name); } }
public void The_saga_expression_should_be_converted_down_to_a_saga_only_filter() { Expression <Func <SimpleSaga, InitiateSimpleSaga, bool> > selector = (s, m) => s.CorrelationId == m.CorrelationId; var filter = new SagaFilterExpressionConverter <SimpleSaga, InitiateSimpleSaga>(_initiateSaga).Convert(selector); Trace.WriteLine(filter.ToString()); var matches = _repository.Where(filter); Assert.AreEqual(1, matches.Count()); }
public void Matching_by_property_should_be_happy() { Expression <Func <SimpleSaga, ObservableSagaMessage, bool> > selector = (s, m) => s.Name == m.Name; Expression <Func <SimpleSaga, bool> > filter = new SagaFilterExpressionConverter <SimpleSaga, ObservableSagaMessage>(_observeSaga).Convert(selector); Trace.WriteLine(filter.ToString()); IEnumerable <SimpleSaga> matches = _repository.Where(filter); Assert.AreEqual(1, matches.Count()); }
public void Heartbeat_signals_should_be_received_by_the_health_monitor() { // give the health client some time to send a couple of heartbeats Thread.Sleep(2.Seconds()); var s = _healthSagas.Where(filter => true).FirstOrDefault(); s.ShouldNotBeNull(); s.ShouldBeInState(HealthSaga.Healthy); }
private static void ReadUserKeyPress() { while (true) { var key = Console.ReadKey(true); if (key.Key.ToString().ToLower() == "r") { Console.Out.WriteLineAsync($"Repo contains: {_updProductsSagaRepo.Count} Sagas!"); var correlationGuids = _updProductsSagaRepo.Where(p => true).ConfigureAwait(false).GetAwaiter().GetResult(); foreach (var corrGuid in correlationGuids) { var saga = _updProductsSagaRepo[corrGuid]; Console.Out.WriteLineAsync($"Saga[{corrGuid}], State: {saga.Instance.CurrentState}, SomethingUnique: {saga.Instance.SomethingUnique}"); } } else { break; } } }