public InitiatedByOrOrchestratesSagaConnectorFactory()
        {
            var consumeFilter = new InitiatedByOrOrchestratesSagaMessageFilter <TSaga, TMessage>();

            ISagaFactory <TSaga, TMessage> sagaFactory = new DefaultSagaFactory <TSaga, TMessage>();

            var policy = new NewOrExistingSagaPolicy <TSaga, TMessage>(sagaFactory, false);

            _connector = new CorrelatedSagaMessageConnector <TSaga, TMessage>(consumeFilter, policy, x => x.Message.CorrelationId);
        }
Exemplo n.º 2
0
        public async Task GivenADocumentDbSagaRepository_WhenSendingAndPolicyReturnsInstance()
        {
            _correlationId     = Guid.NewGuid();
            _cancellationToken = new CancellationToken();

            _context = new Mock <ConsumeContext <InitiateSimpleSaga> >();
            _context.Setup(x => x.CorrelationId).Returns(_correlationId);
            _context.Setup(m => m.CancellationToken).Returns(_cancellationToken);

            _simpleSaga = new SimpleSagaResource {
                CorrelationId = _correlationId
            };

            var sagaFactory = new FactoryMethodSagaFactory <SimpleSagaResource, InitiateSimpleSaga>(x => _simpleSaga);

            _policy = new NewOrExistingSagaPolicy <SimpleSagaResource, InitiateSimpleSaga>(sagaFactory, true);

            _nextPipe = new Mock <IPipe <SagaConsumeContext <SimpleSagaResource, InitiateSimpleSaga> > >();

            _repository = new DocumentDbSagaRepository <SimpleSagaResource>(SagaRepository.Instance.Client, SagaRepository.DatabaseName,
                                                                            SagaRepository.CollectionName);

            await _repository.Send(_context.Object, _policy, _nextPipe.Object);
        }