public TestingContext(Action <ICosmosDbBuilder> builderCallback, Action <ICosmosDbRepositoryBuilder> repoBuilderCallback)
        {
            var services = TestFramework.Services;

            DbConfig   = services.GetRequiredService <IOptions <CosmosDbConfig> >().Value;
            TestConfig = services.GetRequiredService <IOptions <TestConfig> >().Value.Clone();
            EnvConfig  = services.GetRequiredService <IOptions <EnvironmentConfig> >().Value;

            if (EnvConfig.RandomizeCollectionName)
            {
                TestConfig.CollectionName = $"{TestConfig.CollectionName}{Guid.NewGuid()}";
            }

            DbClient = new DocumentClient(new Uri(DbConfig.DbEndPoint), DbConfig.DbKey);
            var builder = new CosmosDbBuilder()
                          .WithId(DbConfig.DbName)
                          .WithDefaultThroughput(400)
                          .AddCollection <T>(TestConfig.CollectionName, repoBuilderCallback);

            builderCallback?.Invoke(builder);

            CosmosDb = builder.Build(DbClient);

            Repo = CosmosDb.Repository <T>();
        }
Esempio n. 2
0
 public Queue(ICosmosDb cosmosDb)
 {
     _queueRepository = cosmosDb.Repository <QueueDocument>();
 }
Esempio n. 3
0
 public Stores(ICosmosDb cosmosDb)
 {
     _storeRepository = cosmosDb.Repository <StoreDocument>();
 }