Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowConstraintViolationIfAskedToIndexPropertyThatIsAlreadyIndexed()
        public virtual void ShouldThrowConstraintViolationIfAskedToIndexPropertyThatIsAlreadyIndexed()
        {
            // GIVEN
            Schema schema;

            using (Transaction tx = _db.beginTx())
            {
                schema = _db.schema();
                Schema.indexFor(_label).on(_propertyKey).create();
                tx.Success();
            }

            // WHEN
            ConstraintViolationException caught = null;

            try
            {
                using (Transaction tx = _db.beginTx())
                {
                    Schema.indexFor(_label).on(_propertyKey).create();
                    tx.Success();
                }
            }
            catch (ConstraintViolationException e)
            {
                caught = e;
            }

            // THEN
            assertThat(caught, not(nullValue()));
        }
Esempio n. 2
0
 private void CreateConstraint(GraphDatabaseService database)
 {
     using (Transaction transaction = database.BeginTx())
     {
         Schema schema = database.Schema();
         Schema.constraintFor(_constraintIndexLabel).assertPropertyIsUnique(UNIQUE_PROPERTY_NAME).create();
         transaction.Success();
     }
 }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowConstraintViolationIfAskedToCreateCompoundConstraint()
        public virtual void ShouldThrowConstraintViolationIfAskedToCreateCompoundConstraint()
        {
            // WHEN
            try
            {
                using (Transaction tx = _db.beginTx())
                {
                    Schema schema = _db.schema();
                    Schema.constraintFor(_label).assertPropertyIsUnique("my_property_key").assertPropertyIsUnique("other_property").create();
                    tx.Success();
                    fail("Should not be able to create constraint on multiple propertyKey keys");
                }
            }
            catch (System.NotSupportedException e)
            {
                assertThat(e.Message, containsString("can only create one unique constraint"));
            }
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowConstraintViolationIfAskedToIndexSamePropertyAndLabelTwiceInSameTx()
        public virtual void ShouldThrowConstraintViolationIfAskedToIndexSamePropertyAndLabelTwiceInSameTx()
        {
            // WHEN
            using (Transaction tx = _db.beginTx())
            {
                Schema schema = _db.schema();
                Schema.indexFor(_label).on(_propertyKey).create();
                try
                {
                    Schema.indexFor(_label).on(_propertyKey).create();
                    fail("Should not have validated");
                }
                catch (ConstraintViolationException e)
                {
                    assertEquals("There already exists an index :MY_LABEL(my_property_key).", e.Message);
                }
                tx.Success();
            }
        }