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 A_correlated_message_should_find_the_correct_saga() { var repository = new NHibernateSagaRepository <TestSaga>(_sessionFactory); var ping = new PingMessage(_sagaId); var initiatePolicy = new InitiatingSagaPolicy <TestSaga, InitiateSimpleSaga>(x => x.CorrelationId, x => false); var message = new InitiateSimpleSaga(_sagaId); var context = message.ToConsumeContext(); repository.GetSaga(context, message.CorrelationId, GetHandlers, initiatePolicy) .Each(x => x(context)); List <TestSaga> sagas = repository.Where(x => x.CorrelationId == _sagaId).ToList(); Assert.AreEqual(1, sagas.Count); Assert.IsNotNull(sagas[0]); Assert.AreEqual(_sagaId, sagas[0].CorrelationId); }
public void Setup() { _sagaId = CombGuid.Generate(); _repository = new InMemorySagaRepository<TestSaga>(); var initiatePolicy = new InitiatingSagaPolicy<TestSaga, InitiateSimpleSaga>(x => x.CorrelationId, x => false); var message = new InitiateSimpleSaga(_sagaId); IConsumeContext<InitiateSimpleSaga> context = message.ToConsumeContext(); _repository.GetSaga(context, message.CorrelationId, (i, c) => InstanceHandlerSelector.ForDataEvent(i, TestSaga.Initiate), initiatePolicy) .Each(x => x(context)); message = new InitiateSimpleSaga(CombGuid.Generate()); context = message.ToConsumeContext(); _repository.GetSaga(context, message.CorrelationId, (i, c) => InstanceHandlerSelector.ForDataEvent(i, TestSaga.Initiate), initiatePolicy) .Each(x => x(context)); }
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(); _repository = new InMemorySagaRepository <TestSaga>(); var initiatePolicy = new InitiatingSagaPolicy <TestSaga, InitiateSimpleSaga>(x => x.CorrelationId, x => false); var message = new InitiateSimpleSaga(_sagaId); IConsumeContext <InitiateSimpleSaga> context = message.ToConsumeContext(); _repository.GetSaga(context, message.CorrelationId, (i, c) => InstanceHandlerSelector.ForDataEvent(i, TestSaga.Initiate), initiatePolicy) .Each(x => x(context)); message = new InitiateSimpleSaga(NewId.NextGuid()); context = message.ToConsumeContext(); _repository.GetSaga(context, message.CorrelationId, (i, c) => InstanceHandlerSelector.ForDataEvent(i, TestSaga.Initiate), initiatePolicy) .Each(x => x(context)); }