public void Setup() { _repository = new InMemorySagaRepository <SimpleSaga>(); var initiatePolicy = new InitiatingSagaPolicy <SimpleSaga, InitiateSimpleSaga>(x => x.CorrelationId, x => false); _sagaId = CombGuid.Generate(); _initiateSaga = new InitiateSimpleSaga { CorrelationId = _sagaId, Name = "Chris" }; var context = _initiateSaga.ToConsumeContext(); _repository.GetSaga(context, _sagaId, (i, c) => InstanceHandlerSelector.ForInitiatedBy <SimpleSaga, InitiateSimpleSaga>(i), initiatePolicy) .Each(x => x(context)); _initiateOtherSaga = new InitiateSimpleSaga { CorrelationId = _otherSagaId, Name = "Dru" }; _otherSagaId = Guid.NewGuid(); context = _initiateOtherSaga.ToConsumeContext(); _repository.GetSaga(context, _otherSagaId, (i, c) => InstanceHandlerSelector.ForInitiatedBy <SimpleSaga, InitiateSimpleSaga>(i), initiatePolicy) .Each(x => x(context)); _observeSaga = new ObservableSagaMessage { Name = "Chris" }; }
public void Setup() { _sagaId = NewId.NextGuid(); _initiateSaga = new InitiateSimpleSaga { CorrelationId = _sagaId, Name = "Chris" }; InputQueueSendEndpoint.Send(_initiateSaga) .Wait(TestCancellationToken); _repository.ShouldContainSaga(_sagaId, TestTimeout) .Wait(TestCancellationToken); _otherSagaId = Guid.NewGuid(); _initiateOtherSaga = new InitiateSimpleSaga { CorrelationId = _otherSagaId, Name = "Dru" }; InputQueueSendEndpoint.Send(_initiateOtherSaga) .Wait(TestCancellationToken); _repository.ShouldContainSaga(_otherSagaId, TestTimeout) .Wait(TestCancellationToken); _observeSaga = new ObservableSagaMessage { Name = "Chris" }; }
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 void Setup() { _repository = new InMemorySagaRepository<SimpleSaga>(); var initiatePolicy = new InitiatingSagaPolicy<SimpleSaga,InitiateSimpleSaga>(x => false); _sagaId = CombGuid.Generate(); _initiateSaga = new InitiateSimpleSaga { CorrelationId = _sagaId, Name = "Chris" }; _repository.Send(x => x.CorrelationId == _sagaId, initiatePolicy, _initiateSaga, saga => saga.Consume(_initiateSaga)); _initiateOtherSaga = new InitiateSimpleSaga {CorrelationId = _otherSagaId, Name = "Dru"}; _otherSagaId = Guid.NewGuid(); _repository.Send(x => x.CorrelationId == _otherSagaId, initiatePolicy, _initiateOtherSaga, saga => saga.Consume(_initiateOtherSaga)); _observeSaga = new ObservableSagaMessage {Name = "Chris"}; }
public void Setup() { _repository = new InMemorySagaRepository<SimpleSaga>(); var initiatePolicy = new InitiatingSagaPolicy<SimpleSaga, InitiateSimpleSaga>(x => x.CorrelationId, x => false); _sagaId = CombGuid.Generate(); _initiateSaga = new InitiateSimpleSaga {CorrelationId = _sagaId, Name = "Chris"}; var context = _initiateSaga.ToConsumeContext(); _repository.GetSaga(context, _sagaId, (i, c) => InstanceHandlerSelector.ForInitiatedBy<SimpleSaga, InitiateSimpleSaga>(i), initiatePolicy) .Each(x => x(context)); _initiateOtherSaga = new InitiateSimpleSaga {CorrelationId = _otherSagaId, Name = "Dru"}; _otherSagaId = Guid.NewGuid(); context = _initiateOtherSaga.ToConsumeContext(); _repository.GetSaga(context, _otherSagaId, (i, c) => InstanceHandlerSelector.ForInitiatedBy<SimpleSaga, InitiateSimpleSaga>(i), initiatePolicy) .Each(x => x(context)); _observeSaga = new ObservableSagaMessage {Name = "Chris"}; }
public void Setup() { _repository = new InMemorySagaRepository <SimpleSaga>(); var initiatePolicy = new InitiatingSagaPolicy <SimpleSaga, InitiateSimpleSaga>(x => false); _sagaId = CombGuid.Generate(); _initiateSaga = new InitiateSimpleSaga { CorrelationId = _sagaId, Name = "Chris" }; _repository.Send(x => x.CorrelationId == _sagaId, initiatePolicy, _initiateSaga, saga => saga.Consume(_initiateSaga)); _initiateOtherSaga = new InitiateSimpleSaga { CorrelationId = _otherSagaId, Name = "Dru" }; _otherSagaId = Guid.NewGuid(); _repository.Send(x => x.CorrelationId == _otherSagaId, initiatePolicy, _initiateOtherSaga, saga => saga.Consume(_initiateOtherSaga)); _observeSaga = new ObservableSagaMessage { Name = "Chris" }; }
public async Task An_observed_message_should_find_and_update_the_correct_saga() { Guid sagaId = NewId.NextGuid(); var message = new InitiateSimpleSaga(sagaId) { Name = "MySimpleSaga" }; await InputQueueSendEndpoint.Send(message); Guid?found = await _sagaRepository.Value.ShouldContainSaga(message.CorrelationId, TestTimeout); found.ShouldBe(sagaId); var nextMessage = new ObservableSagaMessage { Name = "MySimpleSaga" }; await InputQueueSendEndpoint.Send(nextMessage); found = await _sagaRepository.Value.ShouldContainSaga(x => x.CorrelationId == sagaId && x.Observed, TestTimeout); found.ShouldBe(sagaId); }
public void Setup() { _sagaId = NewId.NextGuid(); _initiateSaga = new InitiateSimpleSaga {CorrelationId = _sagaId, Name = "Chris"}; InputQueueSendEndpoint.Send(_initiateSaga) .Wait(TestCancellationToken); _repository.ShouldContainSaga(_sagaId, TestTimeout) .Wait(TestCancellationToken); _otherSagaId = Guid.NewGuid(); _initiateOtherSaga = new InitiateSimpleSaga {CorrelationId = _otherSagaId, Name = "Dru"}; InputQueueSendEndpoint.Send(_initiateOtherSaga) .Wait(TestCancellationToken); _repository.ShouldContainSaga(_otherSagaId, TestTimeout) .Wait(TestCancellationToken); _observeSaga = new ObservableSagaMessage {Name = "Chris"}; }