//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDropUniquenessConstraintWithBackingIndexHavingNoOwner() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDropUniquenessConstraintWithBackingIndexHavingNoOwner() { // given using ( Transaction tx = Db.beginTx() ) { Db.schema().constraintFor(_label).assertPropertyIsUnique(_key).create(); tx.Success(); } // when intentionally breaking the schema by setting the backing index rule to unused RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency( typeof( RecordStorageEngine ) ); SchemaStore schemaStore = storageEngine.TestAccessNeoStores().SchemaStore; SchemaRule indexRule = single( filter( rule => rule is StoreIndexDescriptor, schemaStore.LoadAllSchemaRules() ) ); SetOwnerNull( schemaStore, ( StoreIndexDescriptor ) indexRule ); // At this point the SchemaCache doesn't know about this change so we have to reload it storageEngine.LoadSchemaCache(); using ( Transaction tx = Db.beginTx() ) { single( Db.schema().getConstraints(_label).GetEnumerator() ).drop(); tx.Success(); } // then using ( Transaction ignore = Db.beginTx() ) { assertFalse( Db.schema().Constraints.GetEnumerator().hasNext() ); assertFalse( Db.schema().Indexes.GetEnumerator().hasNext() ); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDropUniquenessConstraintWhereConstraintRecordIsMissingAndIndexHasNoOwner() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldDropUniquenessConstraintWhereConstraintRecordIsMissingAndIndexHasNoOwner() { // given using ( Transaction tx = Db.beginTx() ) { Db.schema().constraintFor(_label).assertPropertyIsUnique(_key).create(); tx.Success(); } // when intentionally breaking the schema by setting the backing index rule to unused RecordStorageEngine storageEngine = Db.DependencyResolver.resolveDependency( typeof( RecordStorageEngine ) ); SchemaStore schemaStore = storageEngine.TestAccessNeoStores().SchemaStore; SchemaRule constraintRule = single( filter( rule => rule is ConstraintRule, schemaStore.LoadAllSchemaRules() ) ); SetSchemaRecordNotInUse( schemaStore, constraintRule.Id ); SchemaRule indexRule = single( filter( rule => rule is StoreIndexDescriptor, schemaStore.LoadAllSchemaRules() ) ); SetOwnerNull( schemaStore, ( StoreIndexDescriptor ) indexRule ); // At this point the SchemaCache doesn't know about this change so we have to reload it storageEngine.LoadSchemaCache(); using ( Transaction tx = Db.beginTx() ) { // We don't use single() here, because it is okay for the schema cache reload to clean up after us. Db.schema().getConstraints(_label).forEach(ConstraintDefinition.drop); Db.schema().getIndexes(_label).forEach(IndexDefinition.drop); tx.Success(); } // then using ( Transaction ignore = Db.beginTx() ) { assertFalse( Db.schema().Constraints.GetEnumerator().hasNext() ); assertFalse( Db.schema().Indexes.GetEnumerator().hasNext() ); } }