public static Task <Guid?> ShouldContainSaga <TSaga>(this InMemorySagaRepository <TSaga> repository, Guid sagaId, TimeSpan timeout) where TSaga : class, ISaga { IQuerySagaRepository <TSaga> querySagaRepository = repository; return(querySagaRepository.ShouldContainSaga(sagaId, timeout)); }
public SagaTestHarness(BusTestHarness testHarness, ISagaRepository <TSaga> repository) { _repository = repository; _querySagaRepository = _repository as IQuerySagaRepository <TSaga>; _testTimeout = testHarness.TestTimeout; _consumed = new ReceivedMessageList(testHarness.TestTimeout); _created = new SagaList <TSaga>(testHarness.TestTimeout); _sagas = new SagaList <TSaga>(testHarness.TestTimeout); TestRepository = new TestSagaRepositoryDecorator <TSaga>(_repository, _consumed, _created, _sagas); testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint; }
public static async Task <Guid?> ShouldContainSaga <TSaga>(this IQuerySagaRepository <TSaga> repository, Guid sagaId, TimeSpan timeout) where TSaga : class, ISaga { DateTime giveUpAt = DateTime.Now + timeout; while (DateTime.Now < giveUpAt) { Guid saga = (await repository.Where(x => x.CorrelationId == sagaId).ConfigureAwait(false)).FirstOrDefault(); if (saga != Guid.Empty) { return(saga); } await Task.Delay(10).ConfigureAwait(false); } return(default);
public SagaTestHarness(BusTestHarness testHarness, ISagaRepository <TSaga> repository, string queueName) { _querySagaRepository = repository as IQuerySagaRepository <TSaga>; TestTimeout = testHarness.TestTimeout; _consumed = new ReceivedMessageList(testHarness.TestTimeout); _created = new SagaList <TSaga>(testHarness.TestTimeout); _sagas = new SagaList <TSaga>(testHarness.TestTimeout); TestRepository = new TestSagaRepositoryDecorator <TSaga>(repository, _consumed, _created, _sagas); if (string.IsNullOrWhiteSpace(queueName)) { testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint; } else { testHarness.OnConfigureBus += configurator => ConfigureNamedReceiveEndpoint(configurator, queueName); } }
public static async Task <Guid?> ShouldContainSaga <TSaga>(this IQuerySagaRepository <TSaga> repository, Expression <Func <TSaga, bool> > filter, TimeSpan timeout) where TSaga : class, ISaga { DateTime giveUpAt = DateTime.Now + timeout; var query = new SagaQuery <TSaga>(filter); while (DateTime.Now < giveUpAt) { var sagas = (await repository.Where(query.FilterExpression).ConfigureAwait(false)).ToList(); if (sagas.Count > 0) { return(sagas.Single()); } await Task.Delay(10).ConfigureAwait(false); } return(default(Guid?)); }
public static Task <IEnumerable <Guid> > Where <TSaga>(this IQuerySagaRepository <TSaga> source, Expression <Func <TSaga, bool> > filter) where TSaga : class, ISaga { return(source.Find(new SagaQuery <TSaga>(filter))); }