public async Task CreateIndex() { await Assert.ThrowsAsync <DuplicateIndexException>(async() => { // Création concurrente -> Une seule création var store = await StoreBuilder.New().CreateAsync(); var schema = await store.Schemas.New <TestDomainDefinition>().CreateAsync(); var domain = await store.DomainModels.New().CreateAsync("Test"); var graph = domain.Resolve <IHyperGraph>() as Hyperstore.Modeling.HyperGraph.HyperGraph; MemoryIndexManager manager = graph.IndexManager as MemoryIndexManager; manager.CreateIndex(schema.Definition.XExtendsBaseClass, "index1", true, "Name"); manager.CreateIndex(schema.Definition.XExtendsBaseClass, "index1", true, "Name"); }); }
public async Task RemoveFromIndex() { var store = await StoreBuilder.New().CreateAsync(); var schema = await store.Schemas.New <TestDomainDefinition>().CreateAsync(); var domain = await store.DomainModels.New().CreateAsync("Test"); var graph = domain.Resolve <IHyperGraph>() as Hyperstore.Modeling.HyperGraph.HyperGraph; MemoryIndexManager manager = graph.IndexManager as MemoryIndexManager; manager.CreateIndex(schema.Definition.XExtendsBaseClass, "index1", true, "Name"); var index = manager.GetIndex("index1"); var id = new Identity("Test", "1"); using (var session = store.BeginSession(new SessionConfiguration { Readonly = true })) { manager.AddToIndex(schema.Definition.XExtendsBaseClass, "index1", id, "momo"); Assert.Equal(id, index.Get("momo")); manager.RemoveFromIndex(schema.Definition.XExtendsBaseClass, "index1", id, "momo"); Assert.Null(index.Get("momo")); } }
public async Task WrongIndexNameTest() { await Assert.ThrowsAsync <InvalidNameException>(async() => { var store = await StoreBuilder.New().CreateAsync(); var schema = await store.Schemas.New <TestDomainDefinition>().CreateAsync(); var domain = await store.DomainModels.New().CreateAsync("Test"); var graph = domain.Resolve <IHyperGraph>() as Hyperstore.Modeling.HyperGraph.HyperGraph; MemoryIndexManager manager = graph.IndexManager as MemoryIndexManager; manager.CreateIndex(schema.Definition.XExtendsBaseClass, "index:1", true, "Name"); }); }
public async Task GetIndex() { var store = await StoreBuilder.New().CreateAsync(); var schema = await store.Schemas.New <TestDomainDefinition>().CreateAsync(); var domain = await store.DomainModels.New().CreateAsync("Test"); var graph = domain.Resolve <IHyperGraph>() as Hyperstore.Modeling.HyperGraph.HyperGraph; MemoryIndexManager manager = graph.IndexManager as MemoryIndexManager; manager.CreateIndex(schema.Definition.XExtendsBaseClass, "index1", true, "Name"); Assert.NotNull(manager.GetIndex("index1")); }
public async Task UniqueConstraintIndex() { await Assert.ThrowsAsync <UniqueConstraintException>(async() => { var store = await StoreBuilder.New().CreateAsync(); var schema = await store.Schemas.New <TestDomainDefinition>().CreateAsync(); var domain = await store.DomainModels.New().CreateAsync("Test"); var graph = domain.Resolve <IHyperGraph>() as Hyperstore.Modeling.HyperGraph.HyperGraph; MemoryIndexManager manager = graph.IndexManager as MemoryIndexManager; using (var s = store.BeginSession(new SessionConfiguration { Readonly = true })) { manager.CreateIndex(schema.Definition.XExtendsBaseClass, "index1", true, "Name"); manager.AddToIndex(schema.Definition.XExtendsBaseClass, "index1", new Identity("Test", "1"), "momo"); manager.AddToIndex(schema.Definition.XExtendsBaseClass, "index1", new Identity("Test", "2"), "momo"); } }); }