Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void should_list_constraints()
        public virtual void ShouldListConstraints()
        {
            // GIVEN
            SchemaCache cache = NewSchemaCache();

            // WHEN
            cache.AddSchemaRule(UniquenessConstraintRule(0L, 1, 2, 133L));
            cache.AddSchemaRule(UniquenessConstraintRule(1L, 3, 4, 133L));
            cache.AddSchemaRule(RelPropertyExistenceConstraintRule(2L, 5, 6));
            cache.AddSchemaRule(NodePropertyExistenceConstraintRule(3L, 7, 8));

            // THEN
            ConstraintDescriptor unique1    = uniqueForLabel(1, 2);
            ConstraintDescriptor unique2    = uniqueForLabel(3, 4);
            ConstraintDescriptor existsRel  = ConstraintDescriptorFactory.existsForRelType(5, 6);
            ConstraintDescriptor existsNode = ConstraintDescriptorFactory.existsForLabel(7, 8);

            assertEquals(asSet(unique1, unique2, existsRel, existsNode), asSet(cache.Constraints()));

            assertEquals(asSet(unique1), asSet(cache.ConstraintsForLabel(1)));

            assertEquals(asSet(unique1), asSet(cache.ConstraintsForSchema(unique1.Schema())));

            assertEquals(asSet(), asSet(cache.ConstraintsForSchema(forLabel(1, 3))));

            assertEquals(asSet(existsRel), asSet(cache.ConstraintsForRelationshipType(5)));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void adding_constraints_should_be_idempotent()
        public virtual void AddingConstraintsShouldBeIdempotent()
        {
            // given
            SchemaCache cache = NewSchemaCache();

            cache.AddSchemaRule(UniquenessConstraintRule(0L, 1, 2, 133L));

            // when
            cache.AddSchemaRule(UniquenessConstraintRule(0L, 1, 2, 133L));

            // then
            assertEquals(asList(uniqueForLabel(1, 2)), Iterators.asList(cache.Constraints()));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void should_remove_constraints()
        public virtual void ShouldRemoveConstraints()
        {
            // GIVEN
            SchemaCache cache = NewSchemaCache();

            cache.AddSchemaRule(UniquenessConstraintRule(0L, 1, 2, 133L));
            cache.AddSchemaRule(UniquenessConstraintRule(1L, 3, 4, 133L));

            // WHEN
            cache.RemoveSchemaRule(0L);

            // THEN
            ConstraintDescriptor dropped = uniqueForLabel(1, 1);
            ConstraintDescriptor unique  = uniqueForLabel(3, 4);

            assertEquals(asSet(unique), asSet(cache.Constraints()));

            assertEquals(asSet(), asSet(cache.ConstraintsForLabel(1)));

            assertEquals(asSet(), asSet(cache.ConstraintsForSchema(dropped.Schema())));
        }