public void Dispose() { var err = new List <Exception>(); foreach (var documentStore in stores) { try { documentStore.Dispose(); } catch (Exception e) { err.Add(e); } } foreach (var ravenDbServer in servers) { try { ravenDbServer.Dispose(); IOExtensions.DeleteDirectory(ravenDbServer.Database.Configuration.DataDirectory); } catch (Exception e) { err.Add(e); } } if (err.Count > 0) { throw new AggregateException(err); } }
public IDocumentStore ResetDatabase(int index) { stores[index].Dispose(); var previousServer = servers[index]; previousServer.Dispose(); IOExtensions.DeleteDirectory(previousServer.Database.Configuration.DataDirectory); return(CreateStoreAtPort(previousServer.Database.Configuration.Port)); }
public void Dispose() { foreach (var documentStore in stores) { documentStore.Dispose(); } foreach (var ravenDbServer in servers) { ravenDbServer.Dispose(); IOExtensions.DeleteDirectory(ravenDbServer.Database.Configuration.DataDirectory); } }
private IDocumentStore CreateStoreAtPort(int port, Action <DocumentStore> configureStore = null) { database::Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port); var assemblyCatalog = new AssemblyCatalog(typeof(replication::Raven.Bundles.Replication.Triggers.AncestryPutTrigger).Assembly); var serverConfiguration = new database::Raven.Database.Config.RavenConfiguration { AnonymousUserAccessMode = database::Raven.Database.Server.AnonymousUserAccessMode.All, Catalog = { Catalogs = { assemblyCatalog } }, DataDirectory = "Data #" + servers.Count, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, RunInMemory = true, Port = port }; ConfigureServer(serverConfiguration); IOExtensions.DeleteDirectory(serverConfiguration.DataDirectory); serverConfiguration.PostInit(); var ravenDbServer = new RavenDbServer(serverConfiguration); ravenDbServer.Server.SetupTenantDatabaseConfiguration += configuration => configuration.Catalog.Catalogs.Add(assemblyCatalog); servers.Add(ravenDbServer); var documentStore = new DocumentStore { Url = ravenDbServer.Database.Configuration.ServerUrl }; ConfigureStore(documentStore); if (configureStore != null) { configureStore(documentStore); } documentStore.Initialize(); documentStore.JsonRequestFactory.EnableBasicAuthenticationOverUnsecureHttpEvenThoughPasswordsWouldBeSentOverTheWireInClearTextToBeStolenByHackers = true; stores.Add(documentStore); return(documentStore); }