Esempio n. 1
0
        public async Task A_correlated_message_should_find_the_correct_saga()
        {
            var sagaId  = NewId.NextGuid();
            var message = new InitiateSimpleSaga(sagaId);

            await InputQueueSendEndpoint.Send(message).ConfigureAwait(false);

            var found = _sagaRepository.Value.ShouldContainSaga(message.CorrelationId, TestTimeout);

            found.ShouldBeTrue();

            var nextMessage = new CompleteSimpleSaga {
                CorrelationId = sagaId
            };

            await InputQueueSendEndpoint.Send(nextMessage).ConfigureAwait(false);

            found = await _sagaRepository.Value.ShouldContainSaga(sagaId, x => x.Completed, TestTimeout).ConfigureAwait(false);

            found.ShouldBeTrue();
            var retrieveRepository = _sagaRepository.Value as IRetrieveSagaFromRepository <SimpleSaga>;
            var retrieved          = retrieveRepository.GetSaga(sagaId);

            retrieved.ShouldNotBeNull();
            retrieved.Completed.ShouldBeTrue();
        }
Esempio n. 2
0
        public async Task A_correlated_message_should_find_the_correct_saga()
        {
            var sagaId  = NewId.NextGuid();
            var message = new InitiateSimpleSaga(sagaId);

            await InputQueueSendEndpoint.Send(message);

            Guid?found = await _sagaRepository.Value.ShouldContainSaga(message.CorrelationId, TestTimeout);

            found.ShouldNotBeNull();

            var nextMessage = new CompleteSimpleSaga {
                CorrelationId = sagaId
            };

            await InputQueueSendEndpoint.Send(nextMessage);

            found = await _sagaRepository.Value.ShouldContainSaga(sagaId, x => x != null && x.Moved, TestTimeout);

            found.ShouldNotBeNull();

            var retrieveRepository = _sagaRepository.Value as ILoadSagaRepository <SimpleSaga>;
            var retrieved          = await retrieveRepository.Load(sagaId);

            retrieved.ShouldNotBeNull();
            retrieved.Moved.ShouldBeTrue();
        }