示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowIllegalArgumentChangingTypeOfFieldOnRelationshipIndex()
        public virtual void ShouldThrowIllegalArgumentChangingTypeOfFieldOnRelationshipIndex()
        {
            string indexName = "index";

            CreateRelationshipExplicitIndexWithSingleRelationship(Db, indexName);

            long relId;

            using (Transaction tx = Db.beginTx())
            {
                Node         node = Db.createNode();
                Relationship rel  = node.CreateRelationshipTo(node, _type);
                relId = rel.Id;
                RelationshipIndex index = Db.index().forRelationships(indexName);
                index.add(rel, "key", "otherValue");
                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                RelationshipIndex index = Db.index().forRelationships(indexName);
                index.remove(Db.getRelationshipById(relId), "key");
                tx.Success();
            }

            ExpectedException.expect(typeof(System.ArgumentException));
            using (Transaction tx = Db.beginTx())
            {
                RelationshipIndex index = Db.index().forRelationships(indexName);
                index.add(Db.getRelationshipById(relId), "key", ValueContext.numeric(52));
                tx.Success();
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void question5346011()
        public virtual void Question5346011()
        {
            GraphDatabaseService service = (new TestGraphDatabaseFactory()).newImpermanentDatabase();

            using (Transaction tx = service.BeginTx())
            {
                RelationshipIndex index = service.Index().forRelationships("exact");
                // ...creation of the nodes and relationship
                Node         node1        = service.CreateNode();
                Node         node2        = service.CreateNode();
                string       uuid         = "xyz";
                Relationship relationship = node1.CreateRelationshipTo(node2, RelationshipType.withName("related"));
                index.add(relationship, "uuid", uuid);
                // query
                using (IndexHits <Relationship> hits = index.Get("uuid", uuid, node1, node2))
                {
                    assertEquals(1, hits.Size());
                }
                tx.Success();
            }
            service.Shutdown();
        }