public async Task GivenACorrelatedMessage_WhenInitiatingAndObservedMessageForSagaArrives_ThenSagaShouldBeLoaded() { _correlationId = Guid.NewGuid(); var initiationMessage = new InitiateSimpleSaga(_correlationId) { Name = "Lee" }; var busControl = await Bus.StartAsync(); await busControl.Publish(initiationMessage); var sagaRepository = new MongoDbQuerySagaRepository <SimpleSaga>(SagaRepository.Instance); var foundId = await sagaRepository.ShouldContainSaga(x => x.Initiated && x.CorrelationId == _correlationId, TimeSpan.FromSeconds(30)); var observableMessage = new ObservableSagaMessage { Name = "Lee" }; await busControl.Publish(observableMessage); foundId = await sagaRepository.ShouldContainSaga(x => x.Observed && x.CorrelationId == _correlationId, TimeSpan.FromSeconds(30)); Assert.That(foundId.HasValue, Is.True); }
public async Task GivenAnInitiatingMessage_WhenPublishing() { _correlationId = Guid.NewGuid(); var message = new InitiateSimpleSaga(_correlationId); var busControl = await Bus.StartAsync(); await busControl.Publish(message); var sagaRepository = new MongoDbQuerySagaRepository <SimpleSaga>(SagaRepository.Instance); _foundId = await sagaRepository.ShouldContainSaga(_correlationId, TimeSpan.FromSeconds(30)); }
public async Task GivenACorrelatedMessage_TheCorrectSagaShouldBeFound() { _correlationId = Guid.NewGuid(); var message = new InitiateSimpleSaga(_correlationId); var busControl = await Bus.StartAsync(); await busControl.Publish(message); var sagaRepository = new MongoDbQuerySagaRepository <SimpleSaga>(SagaRepository.Instance); var foundId = await sagaRepository.ShouldContainSaga(_correlationId, TimeSpan.FromSeconds(5)); Assert.That(foundId.HasValue, Is.True); var nextMessage = new CompleteSimpleSaga(_correlationId); await busControl.Publish(nextMessage); foundId = await sagaRepository.ShouldContainSaga(x => x.CorrelationId == _correlationId && x.Completed, TimeSpan.FromSeconds(5)); Assert.That(foundId.HasValue, Is.True); }