public void CanPassOperationHeadersUsingEmbedded() { using (var documentStore = new EmbeddableDocumentStore { Configuration = new RavenConfiguration { Catalog = { Catalogs = { new TypeCatalog(typeof(RecordOperationHeaders)) } }, DataDirectory = path, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true } }.Initialize()) { RecordOperationHeaders.Hello = null; using(var session = documentStore.OpenSession()) { session.Advanced.DatabaseCommands.OperationsHeaders["Hello"] = "World"; session.Store(new { Bar = "foo"}); session.SaveChanges(); Assert.Equal("World", RecordOperationHeaders.Hello); } } }
public static Configure EmbeddedRavenSubscriptionStorage(this Configure config) { var store = new EmbeddableDocumentStore { ResourceManagerId = DefaultResourceManagerId, DataDirectory = DefaultDataDirectory }; store.Initialize(); return RavenSubscriptionStorage(config, store, "Default"); }
public void SuccessTest1() { using (IDocumentStore documentStore = new EmbeddableDocumentStore { RunInMemory = true }.Initialize()) { dynamic expando = new ExpandoObject(); using (IDocumentSession session = documentStore.OpenSession()) { session.Store(expando); JObject metadata = session.Advanced.GetMetadataFor((ExpandoObject)expando); metadata[PropertyName] = JToken.FromObject(true); session.SaveChanges(); } using (IDocumentSession session = documentStore.OpenSession()) { var loaded = session.Load<dynamic>((string)expando.Id); JObject metadata = session.Advanced.GetMetadataFor((DynamicJsonObject)loaded); JToken token = metadata[PropertyName]; Assert.NotNull(token); Assert.True(token.Value<bool>()); } } }
public void SuccessTest2() { using (IDocumentStore documentStore = new EmbeddableDocumentStore { RunInMemory = true }.Initialize()) { dynamic expando = new ExpandoObject(); using (IDocumentSession session = documentStore.OpenSession()) { session.Store(expando); JObject metadata = session.Advanced.GetMetadataFor((ExpandoObject)expando); metadata[PropertyName] = JToken.FromObject(true); session.SaveChanges(); } using (IDocumentSession session = documentStore.OpenSession()) { dynamic loaded = session.Advanced.LuceneQuery<dynamic>() .WhereEquals("@metadata.Raven-Entity-Name", documentStore.Conventions.GetTypeTagName(typeof(ExpandoObject))) .FirstOrDefault(); Assert.NotNull(loaded); } } }
public void WaitForIndexing(EmbeddableDocumentStore store) { while (store.DocumentDatabase.Statistics.StaleIndexes.Length > 0) { Thread.Sleep(100); } }
public void WillNotSerializeEvents() { IOExtensions.DeleteDirectory("Data"); try { using (var documentStore = new EmbeddableDocumentStore()) { documentStore.Configuration.DataDirectory = "Data"; documentStore.Conventions.CustomizeJsonSerializer = x => x.TypeNameHandling = TypeNameHandling.Auto; documentStore.Initialize(); var bar = new Bar(); var foo = new Foo(); foo.PropertyChanged += bar.FooChanged; using (var session = documentStore.OpenSession()) { session.Store(foo); session.SaveChanges(); } } } finally { IOExtensions.DeleteDirectory("Data"); } }
public EmbeddableDocumentStore NewDocumentStore(string storageType, bool inMemory, int? allocatedMemory) { path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase); path = Path.Combine(path, "TestDb").Substring(6); var documentStore = new EmbeddableDocumentStore() { Configuration = { DataDirectory = path, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, DefaultStorageTypeName = storageType, RunInMemory = inMemory, } }; if (documentStore.Configuration.RunInMemory == false) IOExtensions.DeleteDirectory(path); documentStore.Initialize(); new RavenDocumentsByEntityName().Execute(documentStore); if (allocatedMemory != null && inMemory) { var transactionalStorage = ((TransactionalStorage)documentStore.DocumentDatabase.TransactionalStorage); transactionalStorage.EnsureCapacity(allocatedMemory.Value); } return documentStore; }
public void AllArchetypesShouldBeAbleToBeStored() { var store = new EmbeddableDocumentStore() { RunInMemory = true }; store.Initialize(); int count; using (new DocumentSessionScope(store.OpenSession())) { var archetypeRepository = new ArchetypeRepository(); count = Directory.GetFiles(@"Archetypes\xml\", "*.xml").ToList().Count; foreach (var file in Directory.GetFiles(@"Archetypes\xml\", "*.xml")) { Debug.WriteLine(file); var archetypeString = File.ReadAllText(file); var archetype = new ArchetypeXmlParser().Parse(archetypeString); archetypeRepository.Save(archetype); } } using (var session = store.OpenSession()) { var result = session.Advanced.LuceneQuery<Archetype>().WaitForNonStaleResults().Take(count).ToList(); var ravenCount = result.Count(); Assert.AreEqual(count, ravenCount); } }
public void Install(IWindsorContainer container, IConfigurationStore store) { var documentStore = new EmbeddableDocumentStore { DataDirectory = "data" }; documentStore.Initialize(); container.Register(Component.For<IDocumentStore>().Instance(documentStore)); CreateIndexesForModules(documentStore); }
public QueryResultCountsWithProjections() { store = new EmbeddableDocumentStore() { RunInMemory = true }; store.Initialize(); PopulateDatastore(); }
public void WontCreateDirectory() { var embeddableDocumentStore = new EmbeddableDocumentStore() { Url = "http://localhost:8080" }; embeddableDocumentStore.Initialize(); Assert.Null(embeddableDocumentStore.DocumentDatabase); }
public static Configure EmbeddedRavenPersistence(this Configure config) { var store = new EmbeddableDocumentStore { ResourceManagerId = RavenPersistenceConstants.DefaultResourceManagerId, DataDirectory = RavenPersistenceConstants.DefaultDataDirectory }; return RavenPersistence(config, store); }
public void Can_Store_and_Load_Dynamic_Documents() { //When running in the XUnit GUI strange things happen is we just create a path relative to //the .exe itself, so make our folder in the System temp folder instead ("<user>\AppData\Local\Temp") string directoryName = Path.Combine(Path.GetTempPath(), "ravendb.RavenDynamicDocs"); IOExtensions.DeleteDirectory(directoryName); dynamic person = new CustomDynamicClass(); person.FirstName = "Ellen"; person.LastName = "Adams"; dynamic employee = new ExpandoObject(); employee.Name = "John Smith"; employee.Age = 33; employee.Phones = new ExpandoObject(); employee.Phones.Home = "0111 123123"; employee.Phones.Office = "0772 321123"; employee.Prices = new List<decimal>() { 123.4M, 123432.54M }; using (var db = new EmbeddableDocumentStore() { DataDirectory = directoryName }) { db.Initialize(); using (var session = db.OpenSession()) { session.Store(employee); string idEmployee = employee.Id; session.Store(person); string idPerson = person.Id; //Check that a field called "Id" is added to the dynamic object (as it doesn't already exist) //and that it has something in it (not null and not empty) Assert.False(String.IsNullOrEmpty(idEmployee)); Assert.False(String.IsNullOrEmpty(idPerson)); session.SaveChanges(); session.Advanced.Clear(); //Pull the docs back out of RavenDB and see if the values are the same dynamic employeeLoad = session.Load<object>(idEmployee); Assert.Equal("John Smith", employeeLoad.Name); Assert.Equal("0111 123123", employeeLoad.Phones.Home); Assert.Equal("0772 321123", employeeLoad.Phones.Office); Assert.Contains(123.4D, employeeLoad.Prices); Assert.Contains(123432.54D, employeeLoad.Prices); Assert.IsType<DynamicNullObject>(employeeLoad.Address); dynamic personLoad = session.Load<object>(idPerson); Assert.Equal("Ellen", personLoad.FirstName); Assert.Equal("Adams", personLoad.LastName); Assert.IsType<DynamicNullObject>(personLoad.Age); } } }
public static Configure EmbeddedRavenDBSagaPersister(this Configure config, string dataDirectory) { if (!Sagas.Impl.Configure.SagasWereFound) return config; IDocumentStore documentStore = new EmbeddableDocumentStore { DataDirectory = dataDirectory, }; return config.ConfigureInternal(documentStore); }
public void CreateStore() { store = new EmbeddableDocumentStore { Configuration = new RavenConfiguration { RunInMemory = true } }; store.Initialize(); IndexCreation.CreateIndexes(typeof(ImageTags_GroupByTagName).Assembly, store); }
public static IDocumentStore StartupDb() { NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080); var store = new EmbeddableDocumentStore { DataDirectory = @"App_Data\RavenDB", UseEmbeddedHttpServer = true }; store.Initialize(); return store; }
public void CreateStore() { store = new EmbeddableDocumentStore { Configuration = new RavenConfiguration { RunInMemory = true } }; store.Initialize(); IndexCreation.CreateIndexes(typeof(MonoVersionIndex).Assembly, store); }
public void WontCreateDirectoryWhenSettingStorage() { var embeddableDocumentStore = new EmbeddableDocumentStore() { Configuration = { DefaultStorageTypeName = "munin" }, Url = "http://localhost:8080" }; embeddableDocumentStore.Initialize(); Assert.Null(embeddableDocumentStore.DocumentDatabase); }
public IDocumentStore CreateStore() { var documentStore = new EmbeddableDocumentStore { DataDirectory = "c:\\Raven", RunInMemory = true, UseEmbeddedHttpServer = true, }; documentStore.Initialize(); return documentStore; }
public void Can_perform_Skip_Take_Query() { using (var db = new EmbeddableDocumentStore() { DataDirectory = directoryName }) { db.Initialize(); string indexName = "UserIndex"; using (var session = db.OpenSession()) { AddData(session); db.DatabaseCommands.DeleteIndex(indexName); db.DatabaseCommands.PutIndex<User, User>(indexName, new IndexDefinition<User, User>() { Map = docs => from doc in docs select new { doc.Name, doc.Age }, SortOptions = {{x=>x.Name, SortOptions.StringVal}} }, true); WaitForQueryToComplete(session, indexName); var allResults = session.Query<User>(indexName).OrderBy(x => x.Name) .Where(x => x.Age > 0); Assert.Equal(4, allResults.ToArray().Count()); var takeResults = session.Query<User>(indexName).OrderBy(x => x.Name) .Where(x => x.Age > 0) .Take(3); //There are 4 items of data in the db, but using Take(1) means we should only see 4 Assert.Equal(3, takeResults.ToArray().Count()); var skipResults = session.Query<User>(indexName).OrderBy(x => x.Name) .Where(x => x.Age > 0) .Skip(1); //Using Skip(1) means we should only see the last 3 Assert.Equal(3, skipResults.ToArray().Count()); Assert.DoesNotContain(firstUser, skipResults.ToArray()); var skipTakeResults = session.Query<User>(indexName).OrderBy(x => x.Name) .Where(x => x.Age > 0) .Skip(1) .Take(2); //Using Skip(1), Take(2) means we shouldn't see the 1st or 4th (last) users Assert.Equal(2, skipTakeResults.ToArray().Count()); Assert.DoesNotContain<User>(firstUser, skipTakeResults.ToArray()); Assert.DoesNotContain<User>(lastUser, skipTakeResults.ToArray()); } } }
private DocumentStore NewDocumentStore() { path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase); path = Path.Combine(path, "TestDb").Substring(6); var documentStore = new EmbeddableDocumentStore { Configuration = { DataDirectory = path } }; documentStore.Initialize(); return documentStore; }
private DocumentStore NewDocumentStore() { path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase); path = Path.Combine(path, "TestDb").Substring(6); var documentStore = new EmbeddableDocumentStore() { Configuration = { RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true, DataDirectory = path } }; documentStore.Initialize(); return documentStore; }
public void Setup() { var store = new EmbeddableDocumentStore { RunInMemory = true, DataDirectory = Guid.NewGuid().ToString() }; store.Initialize(); entity = new TestSaga(); entity.Id = Guid.NewGuid(); SetupEntity(entity); var persister = new RavenSagaPersister { Store = store }; persister.Save(entity); savedEntity = persister.Get<TestSaga>(entity.Id); }
private DocumentStore NewDocumentStore() { path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(RavenDBEventStoreTests)).CodeBase); path = Path.Combine(path, "TestDb").Substring(6); if (Directory.Exists(path)) { File.SetAttributes(path, FileAttributes.Directory); Directory.Delete(path, true); } var documentStore = new EmbeddableDocumentStore { DataDirectory = path }; documentStore.Initialize(); return documentStore; }
private DocumentStore CreateDocumentStore() { var store = new EmbeddableDocumentStore { RunInMemory = _inMemory }; if (!_inMemory && _storeDirectory != null) store.DataDirectory = _storeDirectory; store.Initialize(); CreateIndices(store); return store; }
public void CanRunSpatialQueriesInMemory() { var documentStore = new EmbeddableDocumentStore { RunInMemory = true }; documentStore.Initialize(); var def = new IndexDefinition<Listing> { Map = listings => from listingItem in listings select new { listingItem.ClassCodes, listingItem.Latitude, listingItem.Longitude, _ = SpatialIndex.Generate(listingItem.Latitude, listingItem.Longitude) } }; documentStore.DatabaseCommands.PutIndex("RadiusClassifiedSearch", def); }
public void AndEntirelyInMemoryForUberFastTestingHAHAHAHA() { // Application start-up IDocumentStore store = new EmbeddableDocumentStore() { Configuration = new Raven.Database.RavenConfiguration() { RunInMemory = true } }; store.Initialize(); // Per unit of work using (var session = store.OpenSession()) { } }
public EmbeddableDocumentStore NewEmbedableDocumentStore() { path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(LocalClientTest)).CodeBase); path = Path.Combine(path, "TestDb").Substring(6); IOExtensions.DeleteDirectory(path); var documentStore = new EmbeddableDocumentStore() { Configuration = { DataDirectory = path, RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true } }; return documentStore; }
public void AndICanAlsoCanRunInProcess() { // Application start-up IDocumentStore store = new EmbeddableDocumentStore() { Configuration = new Raven.Database.RavenConfiguration() { DataDirectory = "Data" } }; store.Initialize(); // Per unit of work using (var session = store.OpenSession()) { } }
public static void Startup() { var documentStore = new EmbeddableDocumentStore { Configuration = new RavenConfiguration { DataDirectory = "App_Data\\RavenDB", } }; documentStore.Initialize(); IndexCreation.CreateIndexes(typeof(MonoVersionIndex).Assembly, documentStore); FubuApplication .For<WomRegistry>() .StructureMapObjectFactory(x=> x.AddRegistry(new CoreRegistry(documentStore))) .Bootstrap(RouteTable.Routes); }