private ConstraintDefinition Recreate(ConstraintDefinition constraint, int times) { for (int i = 0; i < times; i++) { constraint.Drop(); constraint = _graphDb.schema().constraintFor(constraint.Label).assertPropertyIsUnique(single(constraint.PropertyKeys)).create(); } return(constraint); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void convertConstraintToIndex() public virtual void ConvertConstraintToIndex() { using (Transaction tx = _graphDb.beginTx()) { _graphDb.schema().constraintFor(_label).assertPropertyIsUnique(PROPERTY_KEY).create(); tx.Success(); } using (Transaction tx = _graphDb.beginTx()) { ConstraintDefinition constraint = firstOrNull(_graphDb.schema().getConstraints(_label)); constraint.Drop(); _graphDb.schema().indexFor(_label).on(PROPERTY_KEY).create(); tx.Success(); } // assert no exception is thrown }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleCheckExistenceOfConstraints() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleCheckExistenceOfConstraints() { // GIVEN using (Org.Neo4j.Graphdb.Transaction tx = graphDb.beginTx()) { graphDb.schema().constraintFor(label("FOO")).assertPropertyIsUnique("prop1").create(); ConstraintDefinition dropped = graphDb.schema().constraintFor(label("FOO")).assertPropertyIsUnique("prop2").create(); dropped.Drop(); tx.Success(); } using (Transaction tx = beginTransaction()) { int label = tx.tokenWrite().labelGetOrCreateForName("FOO"); int prop1 = tx.tokenWrite().propertyKeyGetOrCreateForName("prop1"); int prop2 = tx.tokenWrite().propertyKeyGetOrCreateForName("prop2"); // THEN assertTrue(tx.schemaRead().constraintExists(UniqueConstraintDescriptor(label, prop1))); assertFalse(tx.schemaRead().constraintExists(UniqueConstraintDescriptor(label, prop2))); } }