DatabaseContext <TSaga> Factory(IConfigurationServiceProvider provider)
        {
            var client = new DocumentClient(EndpointUri, Key);

            var context = new DocumentDbDatabaseContext <TSaga>(client, DatabaseId, CollectionId ?? DefaultCollectionName, _serializerSettings);

            return(context);
        }
Exemplo n.º 2
0
        public async Task GivenADocumentDbSagaConsumeContext_WhenSettingComplete()
        {
            _saga = new SimpleSaga {
                CorrelationId = Guid.NewGuid()
            };

            await SagaRepository.Instance.InsertSaga(_saga, true);

            var databaseContext = new DocumentDbDatabaseContext <SimpleSaga>(SagaRepository.Instance.Client, SagaRepository.DatabaseName,
                                                                             SagaRepository.CollectionName);

            _documentDbSagaConsumeContext =
                new DocumentDbSagaConsumeContext <SimpleSaga, InitiateSimpleSaga>(databaseContext, Mock.Of <ConsumeContext <InitiateSimpleSaga> >(), _saga,
                                                                                  SagaConsumeContextMode.Insert);

            await _documentDbSagaConsumeContext.SetCompleted();
        }
        public DocumentDbSagaRepository(IDocumentClient client, string databaseName, string collectionName,
                                        JsonSerializerSettings serializerSettings = null)
        {
            if (string.IsNullOrWhiteSpace(collectionName))
            {
                throw new ArgumentNullException(nameof(collectionName));
            }

            if (collectionName.Length > 120)
            {
                throw new ArgumentException("Collection names must be no longer than 120 characters", nameof(collectionName));
            }

            var databaseContext = new DocumentDbDatabaseContext <TSaga>(client, databaseName, collectionName ?? DefaultCollectionName, serializerSettings);

            var consumeContextFactory = new DocumentDbSagaConsumeContextFactory <TSaga>();

            var repositoryFactory = new DocumentDbSagaRepositoryContextFactory <TSaga>(databaseContext, consumeContextFactory);

            _repository = new SagaRepository <TSaga>(repositoryFactory);
        }