Esempio n. 1
0
        public void CreateNodeWithProperties()
        {
            var batch = new BatchStore();

            var prop1 = new Properties();

            prop1.SetProperty("name", "michael");
            prop1.SetProperty("location", "new york");

            var prop2 = new Properties();

            prop2.SetProperty("color", "blue");
            prop2.SetProperty("tree", "elm");

            var batchNode1 = Node.CreateNode(prop1, batch);
            var batchNode2 = Node.CreateNode(prop2, batch);

            Assert.IsTrue(batch.Execute());

            var restNode1 = batch.GetGraphObject(batchNode1);
            var restNode2 = batch.GetGraphObject(batchNode2);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);

            Assert.IsTrue(restNode1.Properties.GetProperty <string>("name") == "michael");
            Assert.IsTrue(restNode1.Properties.GetProperty <string>("location") == "new york");

            Assert.IsTrue(restNode2.Properties.GetProperty <string>("color") == "blue");
            Assert.IsTrue(restNode2.Properties.GetProperty <string>("tree") == "elm");
        }
Esempio n. 2
0
        public void RemoveRelationshipProperties()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var batch = new BatchStore();

            var batchRelationship = Relationship.CreateRelationship(node1, node2, "likes", null, batch);

            batchRelationship.Properties.SetProperty("name", "joe");
            batchRelationship.Properties.SetProperty("age", 12);

            batchRelationship.SaveProperties();

            batchRelationship.Properties.RemoveProperty("age");

            batchRelationship.SaveProperties();

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restRelationship.Properties.GetProperty <string>("name") == "joe");
            Assert.IsTrue(restRelationship.Properties.GetPropertyOrDefault <int>("age") == 0);
        }
Esempio n. 3
0
        public void GetRelationshipWithProperties()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var props = new Properties();

            props.SetProperty("name", "michael");
            props.SetProperty("approved", true);
            props.SetProperty("length", 123);

            var relationship = node1.CreateRelationshipTo(node2, "friend", props);

            var batch             = new BatchStore();
            var batchRelationship = Relationship.GetRelationship(relationship.Id, batch);

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restRelationship == relationship);
            Assert.IsTrue(restRelationship.Properties.GetProperty <string>("name") == "michael");
            Assert.IsTrue(restRelationship.Properties.GetProperty <bool>("approved"));
            Assert.IsTrue(restRelationship.Properties.GetProperty <int>("length") == 123);
        }
Esempio n. 4
0
        public void RemoveNodeToIndex4()
        {
            var batch = new BatchStore();

            var node = Node.CreateNode();

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            node.AddToIndex("nodes", "a", value1);
            node.AddToIndex("nodes", "a", value2);
            node.AddToIndex("nodes", "b", value2);

            Node.RemoveFromIndex(node, "nodes", "a", value2, batch);

            Assert.IsTrue(batch.Execute());

            var nodes1 = Node.GetNode("nodes", "a", value1);
            var nodes2 = Node.GetNode("nodes", "a", value2);
            var nodes3 = Node.GetNode("nodes", "b", value2);

            Assert.IsTrue(nodes1.Count() == 1);
            Assert.IsTrue(nodes2.Count() == 0);
            Assert.IsTrue(nodes3.Count() == 1);

            Assert.IsTrue(nodes1.First() == node);
            Assert.IsTrue(nodes3.First() == node);
        }
Esempio n. 5
0
        public void RemoveRelationshipToIndex4()
        {
            var batch = new BatchStore();

            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var relationship1 = node1.CreateRelationshipTo(node2, "like");

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            relationship1.AddToIndex("relationships", "a", value1);
            relationship1.AddToIndex("relationships", "a", value2);
            relationship1.AddToIndex("relationships", "b", value2);

            Relationship.RemoveFromIndex(relationship1, "relationships", "a", value2, batch);

            Assert.IsTrue(batch.Execute());

            var relationships1 = Relationship.GetRelationship("relationships", "a", value1);
            var relationships2 = Relationship.GetRelationship("relationships", "a", value2);
            var relationships3 = Relationship.GetRelationship("relationships", "b", value2);

            Assert.IsTrue(relationships1.Count() == 1);
            Assert.IsTrue(relationships2.Count() == 0);
            Assert.IsTrue(relationships3.Count() == 1);

            Assert.IsTrue(relationships1.First() == relationship1);
            Assert.IsTrue(relationships3.First() == relationship1);
        }
Esempio n. 6
0
        public void RemoveRelationshpToIndex2()
        {
            var batch = new BatchStore();

            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var relationship1 = node1.CreateRelationshipTo(node2, "like");

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            relationship1.AddToIndex("relationships", "a", value1);
            relationship1.AddToIndex("relationships", "b", value2);

            Relationship.RemoveFromIndex(relationship1, "relationships", null, null, batch);

            Assert.IsTrue(batch.Execute());

            var relationships1 = Relationship.GetRelationship("relationships", "a", value1);
            var relationships2 = Relationship.GetRelationship("relationships", "b", value2);

            Assert.IsTrue(!relationships1.Any());
            Assert.IsTrue(!relationships2.Any());
        }
Esempio n. 7
0
        public void CreateNodeWithProperties()
        {
            var batch = new BatchStore();

            var prop1 = new Properties();
            prop1.SetProperty("name", "michael");
            prop1.SetProperty("location", "new york");

            var prop2 = new Properties();
            prop2.SetProperty("color", "blue");
            prop2.SetProperty("tree", "elm");

            var batchNode1 = Node.CreateNode(prop1, batch);
            var batchNode2 = Node.CreateNode(prop2, batch);

            Assert.IsTrue(batch.Execute());

            var restNode1 = batch.GetGraphObject(batchNode1);
            var restNode2 = batch.GetGraphObject(batchNode2);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);

            Assert.IsTrue(restNode1.Properties.GetProperty<string>("name") == "michael");
            Assert.IsTrue(restNode1.Properties.GetProperty<string>("location") == "new york");

            Assert.IsTrue(restNode2.Properties.GetProperty<string>("color") == "blue");
            Assert.IsTrue(restNode2.Properties.GetProperty<string>("tree") == "elm");
        }
Esempio n. 8
0
        public void CreateRelationshipWithProperties2()
        {
            var batch      = new BatchStore();
            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            var prop = new Properties();

            var since = DateTime.Now;

            prop.SetProperty("since", since);
            prop.SetProperty("approved", true);

            var batchRelationship = Relationship.CreateRelationship(batchNode1, batchNode2, "friend", prop, batch);

            Assert.IsTrue(batch.Execute());

            var restNode1        = batch.GetGraphObject(batchNode1);
            var restNode2        = batch.GetGraphObject(batchNode2);
            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);

            Assert.IsTrue(restRelationship.StartNode == restNode1);
            Assert.IsTrue(restRelationship.EndNode == restNode2);
            Assert.IsTrue(restRelationship.Type == "friend");

            Assert.IsTrue(restRelationship.Properties.GetProperty <DateTime>("since") == since);
            Assert.IsTrue(restRelationship.Properties.GetProperty <bool>("approved"));
        }
Esempio n. 9
0
        public void DeleteBatchNode2()
        {
            var batch = new BatchStore();
            var node  = Node.CreateNode(batch);

            batch.Delete(node);
            batch.Execute();
        }
Esempio n. 10
0
        public void GetAllRelationships1()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);

            batchNode.GetRelationships();

            batch.Execute();
        }
Esempio n. 11
0
        public void CreateNodeNoProperties()
        {
            var batch = new BatchStore();
            var batchNode = Node.CreateNode(null, batch);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            Assert.IsTrue(restNode.Id > 0);
        }
Esempio n. 12
0
        public void CreateNodeNoProperties()
        {
            var batch     = new BatchStore();
            var batchNode = Node.CreateNode(null, batch);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            Assert.IsTrue(restNode.Id > 0);
        }
Esempio n. 13
0
        public void DeleteNode()
        {
            var node = Node.CreateNode();

            var batch = new BatchStore();

            batch.Delete(node);

            Assert.IsTrue(batch.Execute());

            Node.GetNode(node.Id);
        }
Esempio n. 14
0
        public void RemoveNodeToIndex1()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            batchNode.AddToIndex("nodes", "a", value1);

            batchNode.RemoveFromIndex("nodes");
        }
Esempio n. 15
0
        public void GetNode()
        {
            var node = Node.CreateNode();

            var batch     = new BatchStore();
            var batchNode = Node.GetNode(node.Id, batch);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            Assert.IsTrue(node == restNode);
        }
Esempio n. 16
0
        public void CreateTwoNodeNoProperties()
        {
            var batch      = new BatchStore();
            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            Assert.IsTrue(batch.Execute());

            var restNode1 = batch.GetGraphObject(batchNode1);
            var restNode2 = batch.GetGraphObject(batchNode2);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
        }
Esempio n. 17
0
        public void RemoveRelationshpToIndex1()
        {
            var batch = new BatchStore();

            var batchNode1        = Node.CreateNode(batch);
            var batchNode2        = Node.CreateNode(batch);
            var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "like");

            var value1 = UniqueValue();

            batchRelationship.AddToIndex("relationships", "a", value1);

            batchRelationship.RemoveFromIndex("nodes");
        }
Esempio n. 18
0
        public void CreateUniqueNodeInIndex2()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props = new Properties();

            props.SetProperty("name", "jack");

            var node = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.GetOrCreate, props);

            var batchNode = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props, batch);

            //Should fail because dup key in index
            Assert.IsFalse(batch.Execute());
        }
Esempio n. 19
0
        public void AddNodeToIndex()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);

            var value1 = UniqueValue();

            batchNode.AddToIndex("nodes", "a", value1);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            var nodes = Node.GetNode("nodes", "a", value1);
            Assert.IsTrue(nodes.Count() == 1);
            Assert.IsTrue(nodes.First() == restNode);
        }
Esempio n. 20
0
        public void AddNodeToIndex()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);

            var value1 = UniqueValue();

            batchNode.AddToIndex("nodes", "a", value1);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            var nodes = Node.GetNode("nodes", "a", value1);

            Assert.IsTrue(nodes.Count() == 1);
            Assert.IsTrue(nodes.First() == restNode);
        }
Esempio n. 21
0
        public void UpdatePropertyOnNode2()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);

            batchNode.Properties.SetProperty("name", "todd");
            batchNode.Properties.SetProperty("moved", true);
            batchNode.Properties.SetProperty("height", 13);

            batchNode.SaveProperties();

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            Assert.IsTrue(restNode.Properties.GetProperty <string>("name") == "todd");
            Assert.IsTrue(restNode.Properties.GetProperty <bool>("moved"));
            Assert.IsTrue(restNode.Properties.GetProperty <int>("height") == 13);
        }
Esempio n. 22
0
        public void CreateRelationshipNoProperties2()
        {
            var batch      = new BatchStore();
            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            var batchRelationship = Relationship.CreateRelationship(batchNode1, batchNode2, "friend", null, batch);

            Assert.IsTrue(batch.Execute());

            var restNode1        = batch.GetGraphObject(batchNode1);
            var restNode2        = batch.GetGraphObject(batchNode2);
            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);

            Assert.IsTrue(restRelationship.StartNode == restNode1);
            Assert.IsTrue(restRelationship.EndNode == restNode2);
            Assert.IsTrue(restRelationship.Type == "friend");
        }
Esempio n. 23
0
        public void AddRelationshipsToIndex()
        {
            var batch = new BatchStore();

            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "friend");

            var value1 = UniqueValue();

            batchRelationship.AddToIndex("relationships", "a", value1);

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            var relationships = Relationship.GetRelationship("relationships", "a", value1);
            Assert.IsTrue(relationships.Count() == 1);
            Assert.IsTrue(relationships.First() == restRelationship);
        }
Esempio n. 24
0
        public void AddRelationshipsToIndex()
        {
            var batch = new BatchStore();

            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "friend");

            var value1 = UniqueValue();

            batchRelationship.AddToIndex("relationships", "a", value1);

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            var relationships = Relationship.GetRelationship("relationships", "a", value1);

            Assert.IsTrue(relationships.Count() == 1);
            Assert.IsTrue(relationships.First() == restRelationship);
        }
Esempio n. 25
0
        public void CreateUniqueNodeInIndex1()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props = new Properties();

            props.SetProperty("name", "jack");

            var batchNode = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props, batch);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            var nodes = Node.GetNode("nodes", "a", value1);

            Assert.IsTrue(nodes.Count() == 1);
            Assert.IsTrue(nodes.First() == restNode);
            Assert.IsTrue(restNode.Properties.GetProperty <string>("name") == "jack");
        }
Esempio n. 26
0
        public void RemoveNodeToIndex2()
        {
            var batch = new BatchStore();

            var node = Node.CreateNode();

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            node.AddToIndex("nodes", "a", value1);
            node.AddToIndex("nodes", "b", value2);

            Node.RemoveFromIndex(node, "nodes", null, null, batch);

            Assert.IsTrue(batch.Execute());

            var nodes1 = Node.GetNode("nodes", "a", value1);
            var nodes2 = Node.GetNode("nodes", "b", value2);

            Assert.IsTrue(!nodes1.Any());
            Assert.IsTrue(!nodes2.Any());
        }
Esempio n. 27
0
        public void GetAllRelationships2()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();
            var node3 = Node.CreateNode();
            var node4 = Node.CreateNode();

            var restRelationship1 = node1.CreateRelationshipTo(node2, "like");
            var restRelationship2 = node1.CreateRelationshipTo(node3, "like");
            var restRelationship3 = node1.CreateRelationshipTo(node4, "like");

            var batch = new BatchStore();
            var batchRelationships = batch.GetRelationships(node1, RelationshipDirection.All);

            Assert.IsTrue(batch.Execute());

            var restRelationships = batch.GetGraphObject(batchRelationships);

            Assert.IsNotNull(restRelationships);

            Assert.IsTrue(restRelationships.Count() == 3);
        }
Esempio n. 28
0
        public void CreateUniqueNodeInIndex3()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props1 = new Properties();

            props1.SetProperty("name", "jack");

            var props2 = new Properties();

            props2.SetProperty("name", "frank");

            var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props1, batch);
            var batchNode2 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props2, batch);

            //var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, null, batch);
            //var batchNode2 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, null, batch);


            Assert.IsFalse(batch.Execute());
        }
Esempio n. 29
0
        public void UpdateRelationshipProperties1()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var batch = new BatchStore();

            var batchRelationship = Relationship.CreateRelationship(node1, node2, "likes", null, batch);

            batchRelationship.Properties.SetProperty("name", "todd");
            batchRelationship.Properties.SetProperty("moved", true);
            batchRelationship.Properties.SetProperty("height", 13);

            batchRelationship.SaveProperties();

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restRelationship.Properties.GetProperty <string>("name") == "todd");
            Assert.IsTrue(restRelationship.Properties.GetProperty <bool>("moved"));
            Assert.IsTrue(restRelationship.Properties.GetProperty <int>("height") == 13);
        }
Esempio n. 30
0
        public void GetAllRelationships2()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();
            var node3 = Node.CreateNode();
            var node4 = Node.CreateNode();

            var restRelationship1 = node1.CreateRelationshipTo(node2, "like");
            var restRelationship2 = node1.CreateRelationshipTo(node3, "like");
            var restRelationship3 = node1.CreateRelationshipTo(node4, "like");

            var batch = new BatchStore();
            var batchRelationships = batch.GetRelationships(node1, RelationshipDirection.All);

            Assert.IsTrue(batch.Execute());

            var restRelationships = batch.GetGraphObject(batchRelationships);

            Assert.IsNotNull(restRelationships);

            Assert.IsTrue(restRelationships.Count() == 3);
        }
Esempio n. 31
0
        public void GetNode()
        {
            var node = Node.CreateNode();

            var batch = new BatchStore();
            var batchNode = Node.GetNode(node.Id, batch);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            Assert.IsTrue(node == restNode);
        }
Esempio n. 32
0
        public void CreateRelationshipNoProperties2()
        {
            var batch = new BatchStore();
            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            var batchRelationship = Relationship.CreateRelationship(batchNode1, batchNode2, "friend", null, batch);

            Assert.IsTrue(batch.Execute());

            var restNode1 = batch.GetGraphObject(batchNode1);
            var restNode2 = batch.GetGraphObject(batchNode2);
            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);

            Assert.IsTrue(restRelationship.StartNode == restNode1);
            Assert.IsTrue(restRelationship.EndNode == restNode2);
            Assert.IsTrue(restRelationship.Type == "friend");
        }
Esempio n. 33
0
        public void CreateRelationshipWithProperties2()
        {
            var batch = new BatchStore();
            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            var prop = new Properties();

            var since = DateTime.Now;

            prop.SetProperty("since", since);
            prop.SetProperty("approved", true);

            var batchRelationship = Relationship.CreateRelationship(batchNode1, batchNode2, "friend", prop, batch);

            Assert.IsTrue(batch.Execute());

            var restNode1 = batch.GetGraphObject(batchNode1);
            var restNode2 = batch.GetGraphObject(batchNode2);
            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);

            Assert.IsTrue(restRelationship.StartNode == restNode1);
            Assert.IsTrue(restRelationship.EndNode == restNode2);
            Assert.IsTrue(restRelationship.Type == "friend");

            Assert.IsTrue(restRelationship.Properties.GetProperty<DateTime>("since") == since);
            Assert.IsTrue(restRelationship.Properties.GetProperty<bool>("approved"));
        }
Esempio n. 34
0
        public void CreateUniqueNodeInIndex1()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props = new Properties();
            props.SetProperty("name", "jack");

            var batchNode = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props, batch);

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            var nodes = Node.GetNode("nodes", "a", value1);

            Assert.IsTrue(nodes.Count() == 1);
            Assert.IsTrue(nodes.First() == restNode);
            Assert.IsTrue(restNode.Properties.GetProperty<string>("name") == "jack");
        }
Esempio n. 35
0
        public void CreateUniqueNodeInIndex3()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props1 = new Properties();
            props1.SetProperty("name", "jack");

            var props2 = new Properties();
            props2.SetProperty("name", "frank");

            var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props1, batch);
            var batchNode2 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props2, batch);

            //var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, null, batch);
            //var batchNode2 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, null, batch);

            Assert.IsFalse(batch.Execute());
        }
Esempio n. 36
0
        public void DeleteBatchNode2()
        {
            var batch = new BatchStore();
            var node = Node.CreateNode(batch);

            batch.Delete(node);
            batch.Execute();
        }
Esempio n. 37
0
        public void RemoveRelationshpToIndex1()
        {
            var batch = new BatchStore();

            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);
            var batchRelationship = batchNode1.CreateRelationshipTo(batchNode2, "like");

            var value1 = UniqueValue();

            batchRelationship.AddToIndex("relationships", "a", value1);

            batchRelationship.RemoveFromIndex("nodes");
        }
Esempio n. 38
0
        public void RemoveRelationshipToIndex4()
        {
            var batch = new BatchStore();

            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var relationship1 = node1.CreateRelationshipTo(node2, "like");

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            relationship1.AddToIndex("relationships", "a", value1);
            relationship1.AddToIndex("relationships", "a", value2);
            relationship1.AddToIndex("relationships", "b", value2);

            Relationship.RemoveFromIndex(relationship1, "relationships", "a", value2, batch);

            Assert.IsTrue(batch.Execute());

            var relationships1 = Relationship.GetRelationship("relationships", "a", value1);
            var relationships2 = Relationship.GetRelationship("relationships", "a", value2);
            var relationships3 = Relationship.GetRelationship("relationships", "b", value2);

            Assert.IsTrue(relationships1.Count() == 1);
            Assert.IsTrue(relationships2.Count() == 0);
            Assert.IsTrue(relationships3.Count() == 1);

            Assert.IsTrue(relationships1.First() == relationship1);
            Assert.IsTrue(relationships3.First() == relationship1);
        }
Esempio n. 39
0
        public void RemoveRelationshpToIndex2()
        {
            var batch = new BatchStore();

            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var relationship1 = node1.CreateRelationshipTo(node2, "like");

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            relationship1.AddToIndex("relationships", "a", value1);
            relationship1.AddToIndex("relationships", "b", value2);

            Relationship.RemoveFromIndex(relationship1, "relationships", null, null, batch);

            Assert.IsTrue(batch.Execute());

            var relationships1 = Relationship.GetRelationship("relationships", "a", value1);
            var relationships2 = Relationship.GetRelationship("relationships", "b", value2);

            Assert.IsTrue(!relationships1.Any());
            Assert.IsTrue(!relationships2.Any());
        }
Esempio n. 40
0
        public void UpdatePropertyOnNode2()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);

            batchNode.Properties.SetProperty("name", "todd");
            batchNode.Properties.SetProperty("moved", true);
            batchNode.Properties.SetProperty("height", 13);

            batchNode.SaveProperties();

            Assert.IsTrue(batch.Execute());

            var restNode = batch.GetGraphObject(batchNode);

            Assert.IsTrue(restNode.Properties.GetProperty<string>("name") == "todd");
            Assert.IsTrue(restNode.Properties.GetProperty<bool>("moved"));
            Assert.IsTrue(restNode.Properties.GetProperty<int>("height") == 13);
        }
Esempio n. 41
0
        public void CreateUniqueNodeUpdateIndexValueDupFail()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props1 = new Properties();

            props1.SetProperty("name", "jack");
            props1.SetProperty("a", value1);

            var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props1, batch);

            var insertResult = batch.Execute();

            Assert.IsTrue(insertResult);

            var graphNode = batch.GetGraphObject(batchNode1);

            // try to update unique index value.
            batch = new BatchStore();
            var value2 = UniqueValue();

            // create node with new value - will fail because value already exists.
            var fakeNode = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, null, batch);

            // delete old node from index
            Node.RemoveFromIndex(graphNode, "nodes", "a", null, batch);

            // update properties on node
            Node.SetProperty(graphNode, "a", value2, batch);
            Node.SetProperty(graphNode, "name", "tom", batch);

            // add node to index with new key/value for index
            Node.AddToIndex(graphNode, "nodes", "a", value2, batch);

            // execute batch
            var updateResult = batch.Execute();

            if (updateResult)
            {
                fakeNode = batch.GetGraphObject(fakeNode);
                // remove fake node
                fakeNode.RemoveFromIndex("nodes");
                fakeNode.Delete();
            }

            Assert.IsFalse(updateResult);

            //verify old key is in index
            var findNode = Node.GetNode("nodes", "a", value1);

            Assert.IsTrue(findNode.Count() == 1);
            Assert.IsTrue(findNode.First().GetProperty("a").ToString() == value1);


            //verify new key is not in index
            var missingNode = Node.GetNode("nodes", "a", value2);

            Assert.IsFalse(missingNode.Any());
        }
Esempio n. 42
0
        public void GetAllRelationships1()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);
            batchNode.GetRelationships();

            batch.Execute();
        }
Esempio n. 43
0
        public void RemoveRelationshipProperties()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var batch = new BatchStore();

            var batchRelationship = Relationship.CreateRelationship(node1, node2, "likes", null, batch);
            batchRelationship.Properties.SetProperty("name", "joe");
            batchRelationship.Properties.SetProperty("age", 12);

            batchRelationship.SaveProperties();

            batchRelationship.Properties.RemoveProperty("age");

            batchRelationship.SaveProperties();

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restRelationship.Properties.GetProperty<string>("name") == "joe");
            Assert.IsTrue(restRelationship.Properties.GetPropertyOrDefault<int>("age") == 0);
        }
Esempio n. 44
0
        public void DeleteNode()
        {
            var node = Node.CreateNode();

            var batch = new BatchStore();

            batch.Delete(node);

            Assert.IsTrue(batch.Execute());

            Node.GetNode(node.Id);
        }
Esempio n. 45
0
        public void RemoveNodeToIndex4()
        {
            var batch = new BatchStore();

            var node = Node.CreateNode();

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            node.AddToIndex("nodes", "a", value1);
            node.AddToIndex("nodes", "a", value2);
            node.AddToIndex("nodes", "b", value2);

            Node.RemoveFromIndex(node, "nodes", "a", value2, batch);

            Assert.IsTrue(batch.Execute());

            var nodes1 = Node.GetNode("nodes", "a", value1);
            var nodes2 = Node.GetNode("nodes", "a", value2);
            var nodes3 = Node.GetNode("nodes", "b", value2);

            Assert.IsTrue(nodes1.Count() == 1);
            Assert.IsTrue(nodes2.Count() == 0);
            Assert.IsTrue(nodes3.Count() == 1);

            Assert.IsTrue(nodes1.First() == node);
            Assert.IsTrue(nodes3.First() == node);
        }
Esempio n. 46
0
        public void CreateUniqueNodeUpdateIndexValueDupFail()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props1 = new Properties();
            props1.SetProperty("name", "jack");
            props1.SetProperty("a", value1);

            var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props1, batch);

            var insertResult = batch.Execute();

            Assert.IsTrue(insertResult);

            var graphNode = batch.GetGraphObject(batchNode1);

            // try to update unique index value.
            batch = new BatchStore();
            var value2 = UniqueValue();

            // create node with new value - will fail because value already exists.
            var fakeNode = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, null, batch);

            // delete old node from index
            Node.RemoveFromIndex(graphNode, "nodes", "a", null, batch);

            // update properties on node
            Node.SetProperty(graphNode, "a", value2,batch);
            Node.SetProperty(graphNode, "name", "tom", batch);

            // add node to index with new key/value for index
            Node.AddToIndex(graphNode, "nodes", "a", value2, batch);

            // execute batch
            var updateResult = batch.Execute();

            if (updateResult)
            {
                fakeNode = batch.GetGraphObject(fakeNode);
                // remove fake node
                fakeNode.RemoveFromIndex("nodes");
                fakeNode.Delete();
            }

            Assert.IsFalse(updateResult);

            //verify old key is in index
            var findNode = Node.GetNode("nodes", "a", value1);

            Assert.IsTrue(findNode.Count() == 1);
            Assert.IsTrue(findNode.First().GetProperty("a").ToString() == value1);

            //verify new key is not in index
            var missingNode = Node.GetNode("nodes", "a", value2);

            Assert.IsFalse(missingNode.Any());
        }
Esempio n. 47
0
        public void RemoveNodeToIndex2()
        {
            var batch = new BatchStore();

            var node = Node.CreateNode();

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            node.AddToIndex("nodes", "a", value1);
            node.AddToIndex("nodes", "b", value2);

            Node.RemoveFromIndex(node, "nodes", null, null, batch);

            Assert.IsTrue(batch.Execute());

            var nodes1 = Node.GetNode("nodes", "a", value1);
            var nodes2 = Node.GetNode("nodes", "b", value2);

            Assert.IsTrue(!nodes1.Any());
            Assert.IsTrue(!nodes2.Any());
        }
Esempio n. 48
0
        public void CreateUniqueNodeInIndex2()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props = new Properties();
            props.SetProperty("name", "jack");

            var node = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.GetOrCreate, props);

            var batchNode = Node.CreateUniqueNode("nodes", "a", value1, IndexUniqueness.CreateOrFail, props, batch);

            //Should fail because dup key in index
            Assert.IsFalse(batch.Execute());
        }
Esempio n. 49
0
        public void RemoveNodeToIndex1()
        {
            var batch = new BatchStore();

            var batchNode = Node.CreateNode(batch);

            var value1 = UniqueValue();
            var value2 = UniqueValue();

            batchNode.AddToIndex("nodes", "a", value1);

            batchNode.RemoveFromIndex("nodes");
        }
Esempio n. 50
0
        public void CreateTwoNodeNoProperties()
        {
            var batch = new BatchStore();
            var batchNode1 = Node.CreateNode(batch);
            var batchNode2 = Node.CreateNode(batch);

            Assert.IsTrue(batch.Execute());

            var restNode1 = batch.GetGraphObject(batchNode1);
            var restNode2 = batch.GetGraphObject(batchNode2);

            Assert.IsTrue(restNode1.Id > 0);
            Assert.IsTrue(restNode2.Id > 0 && restNode1.Id != restNode2.Id);
        }
Esempio n. 51
0
        public void GetRelationshipWithProperties()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var props = new Properties();
            props.SetProperty("name", "michael");
            props.SetProperty("approved", true);
            props.SetProperty("length", 123);

            var relationship = node1.CreateRelationshipTo(node2, "friend", props);

            var batch = new BatchStore();
            var batchRelationship = Relationship.GetRelationship(relationship.Id, batch);

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restRelationship == relationship);
            Assert.IsTrue(restRelationship.Properties.GetProperty<string>("name") == "michael");
            Assert.IsTrue(restRelationship.Properties.GetProperty<bool>("approved"));
            Assert.IsTrue(restRelationship.Properties.GetProperty<int>("length") == 123);
        }
Esempio n. 52
0
        public void UpdateRelationshipProperties1()
        {
            var node1 = Node.CreateNode();
            var node2 = Node.CreateNode();

            var batch = new BatchStore();

            var batchRelationship = Relationship.CreateRelationship(node1, node2, "likes", null, batch);

            batchRelationship.Properties.SetProperty("name", "todd");
            batchRelationship.Properties.SetProperty("moved", true);
            batchRelationship.Properties.SetProperty("height", 13);

            batchRelationship.SaveProperties();

            Assert.IsTrue(batch.Execute());

            var restRelationship = batch.GetGraphObject(batchRelationship);

            Assert.IsTrue(restRelationship.Properties.GetProperty<string>("name") == "todd");
            Assert.IsTrue(restRelationship.Properties.GetProperty<bool>("moved"));
            Assert.IsTrue(restRelationship.Properties.GetProperty<int>("height") == 13);
        }
Esempio n. 53
0
 public BatchNodeStore(BatchStore batchStore)
 {
     _batchStore = batchStore;
 }
 public BatchRelationshipStore(BatchStore batchStore)
 {
     _batchStore = batchStore;
 }
Esempio n. 55
0
        public void CreateUniqueNodeInIndex2()
        {
            var batch = new BatchStore();

            var value1 = UniqueValue();

            var props1 = new Properties();
            props1.SetProperty("name", "jack");

            var props2 = new Properties();
            props2.SetProperty("name", "frank");

            var batchNode1 = Node.CreateUniqueNode("nodes", "a", value1, props1, batch);
            var batchNode2 = Node.CreateUniqueNode("nodes", "a", value1, props2, batch);

            Assert.IsTrue(batch.Execute());

            var restNode1 = batch.GetGraphObject(batchNode1);
            var restNode2 = batch.GetGraphObject(batchNode2);

            var nodes = Node.GetNode("nodes", "a", value1);

            Assert.IsTrue(nodes.Count() == 1);
            Assert.IsTrue(nodes.First() == restNode1);
            Assert.IsTrue(restNode1 == restNode2);
            Assert.IsTrue(restNode1.Properties.GetProperty<string>("name") == "jack");
        }