//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void nodeKeyConstraintRuleNameMustNotBeTheEmptyString()
        public virtual void NodeKeyConstraintRuleNameMustNotBeTheEmptyString()
        {
            //noinspection RedundantStringConstructorCall
            string name = "";

            ConstraintRule.ConstraintRuleConflict(RULE_ID, ConstraintDescriptorFactory.nodeKeyForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID_2, name);
        }
        // READ CONSTRAINT

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static ConstraintRule readConstraintRule(long id, ByteBuffer source) throws org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException
        private static ConstraintRule ReadConstraintRule(long id, ByteBuffer source)
        {
            SchemaDescriptor schema;
            sbyte            constraintRuleType = source.get();
            string           name;

            switch (constraintRuleType)
            {
            case EXISTS_CONSTRAINT:
                schema = ReadSchema(source);
                name   = ReadRuleName(source).orElse(null);
                return(ConstraintRule.ConstraintRuleConflict(id, ConstraintDescriptorFactory.existsForSchema(schema), name));

            case UNIQUE_CONSTRAINT:
                long ownedUniqueIndex = source.Long;
                schema = ReadSchema(source);
                UniquenessConstraintDescriptor descriptor = ConstraintDescriptorFactory.uniqueForSchema(schema);
                name = ReadRuleName(source).orElse(null);
                return(ConstraintRule.ConstraintRuleConflict(id, descriptor, ownedUniqueIndex, name));

            case UNIQUE_EXISTS_CONSTRAINT:
                long ownedNodeKeyIndex = source.Long;
                schema = ReadSchema(source);
                NodeKeyConstraintDescriptor nodeKeyConstraintDescriptor = ConstraintDescriptorFactory.nodeKeyForSchema(schema);
                name = ReadRuleName(source).orElse(null);
                return(ConstraintRule.ConstraintRuleConflict(id, nodeKeyConstraintDescriptor, ownedNodeKeyIndex, name));

            default:
                throw new MalformedSchemaRuleException(format("Got unknown constraint rule type '%d'.", constraintRuleType));
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rulesCreatedWithNameMustRetainGivenNameAfterDeserialisation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RulesCreatedWithNameMustRetainGivenNameAfterDeserialisation()
        {
            string name = "custom_rule";

            assertThat(SerialiseAndDeserialise(NamedForLabel(name, LABEL_ID, PROPERTY_ID_1).withId(RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedUniqueForLabel(name, LABEL_ID, PROPERTY_ID_1).withIds(RULE_ID_2, RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedForLabel(name, LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withId(RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedUniqueForLabel(name, LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withIds(RULE_ID_2, RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(NamedForLabel(name, LABEL_ID, IntStream.range(1, 200).toArray()).withId(RULE_ID)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1), name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.uniqueForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.nodeKeyForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1), name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is(name));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is(name));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rulesCreatedWithNullNameMustRetainComputedNameAfterDeserialisation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RulesCreatedWithNullNameMustRetainComputedNameAfterDeserialisation()
        {
            assertThat(SerialiseAndDeserialise(ForLabel(LABEL_ID, PROPERTY_ID_1).withId(RULE_ID)).Name, @is("index_1"));
            assertThat(SerialiseAndDeserialise(UniqueForLabel(LABEL_ID, PROPERTY_ID_1).withIds(RULE_ID_2, RULE_ID)).Name, @is("index_2"));
            assertThat(SerialiseAndDeserialise(ForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withId(RULE_ID)).Name, @is("index_1"));
            assertThat(SerialiseAndDeserialise(UniqueForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2).withIds(RULE_ID_2, RULE_ID)).Name, @is("index_2"));
            assertThat(SerialiseAndDeserialise(ForLabel(LABEL_ID, IntStream.range(1, 200).toArray()).withId(RULE_ID)).Name, @is("index_1"));

            string name = null;

            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1), name)).Name, @is("constraint_1"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.uniqueForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is("constraint_2"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.ConstraintRuleConflict(RULE_ID_2, ConstraintDescriptorFactory.nodeKeyForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID, name)).Name, @is("constraint_2"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1), name)).Name, @is("constraint_2"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID, ConstraintDescriptorFactory.existsForLabel(LABEL_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is("constraint_1"));
            assertThat(SerialiseAndDeserialise(ConstraintRule.constraintRule(RULE_ID_2, ConstraintDescriptorFactory.existsForRelType(REL_TYPE_ID, PROPERTY_ID_1, PROPERTY_ID_2), name)).Name, @is("constraint_2"));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void nodeKeyConstraintRuleNameMustNotContainNullCharacter()
        public virtual void NodeKeyConstraintRuleNameMustNotContainNullCharacter()
        {
            string name = "a\0b";

            ConstraintRule.ConstraintRuleConflict(RULE_ID, ConstraintDescriptorFactory.nodeKeyForLabel(LABEL_ID, PROPERTY_ID_1), RULE_ID_2, name);
        }