public CosmosDbEventStoreTests() { _snapshotProviderMock = new Mock <ISnapshotBehaviorProvider>(); EventStoreAzureDbContext.Activate(new AzureDbConfiguration("https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==")) .GetAwaiter().GetResult(); _cosmosDbEventStore = GetCosmosDbEventStore(); }
//[GlobalSetup(Targets = new[] { nameof(RehydrateAggregate) })] //public void GlobalSetup_Storage() //{ // CleanDatabases(); // StoreNDomainEvents(); //} #endregion #region Private methods private void CleanDatabases() { EventStoreAzureDbContext.Activate( new AzureDbConfiguration(GetConnectionInfos().URI, GetConnectionInfos().ConnectionString)); var docs = EventStoreAzureDbContext.Client.CreateDocumentQuery <Event>(EventStoreAzureDbContext.EventsDatabaseLink).AsDocumentQuery(); while (docs.HasMoreResults) { docs.ExecuteNextAsync <Document>().GetAwaiter().GetResult() .DoForEach(e => EventStoreAzureDbContext.Client.DeleteDocumentAsync(documentLink: e.SelfLink).GetAwaiter().GetResult()); } }
/// <summary> /// Use CosmosDB DocumentDB with a one or multiple server urls. /// Multiples urls are usefull when a replica set has been created. /// </summary> /// <param name="bootstrapper">Bootstrapper instance.</param> /// <param name="endPointUrl">Url of CosmosDB host server.</param> /// <param name="primaryKey">DataBase primary key</param> /// <returns>Bootstrapper instance.</returns> public static Bootstrapper UseCosmosDbAsEventStore(this Bootstrapper bootstrapper, string endPointUrl, string primaryKey) { if (string.IsNullOrEmpty(endPointUrl)) { throw new ArgumentNullException("BootstrapperExtensions.UseCosmosDbAsEventStore : endPointUrl have to be definied to use CosmosDb Event Store.", nameof(endPointUrl)); } if (string.IsNullOrEmpty(primaryKey)) { throw new ArgumentNullException("BootstrapperExtensions.UseCosmosDbAsEventStore : primarykey have to be definied to use CosmosDb Event Store.", nameof(primaryKey)); } var service = new CosmosDbEventStoreBootstrappService { BootstrappAction = (ctx) => { EventStoreAzureDbContext.Activate(new AzureDbConfiguration(endPointUrl, primaryKey)) .GetAwaiter().GetResult(); } }; bootstrapper.AddService(service); return(bootstrapper); }