//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateRelationshipWithLabelCountsWhenDeletingNodesWithRelationships() public virtual void ShouldUpdateRelationshipWithLabelCountsWhenDeletingNodesWithRelationships() { // given int numberOfNodes = 2; Node[] nodes = new Node[numberOfNodes]; using (Transaction tx = Db.beginTx()) { for (int i = 0; i < numberOfNodes; i++) { Node foo = Db.createNode(label("Foo" + i)); foo.AddLabel(Label.label("Common")); Node bar = Db.createNode(label("Bar" + i)); foo.CreateRelationshipTo(bar, withName("BAZ" + i)); nodes[i] = foo; } tx.Success(); } long[] beforeCommon = new long[numberOfNodes]; long[] before = new long[numberOfNodes]; for (int i = 0; i < numberOfNodes; i++) { beforeCommon[i] = NumberOfRelationshipsMatching(label("Common"), withName("BAZ" + i), null); before[i] = NumberOfRelationshipsMatching(label("Foo" + i), withName("BAZ" + i), null); } // when using (Transaction tx = Db.beginTx()) { foreach (Node node in nodes) { foreach (Relationship relationship in node.Relationships) { relationship.Delete(); } node.Delete(); } tx.Success(); } long[] afterCommon = new long[numberOfNodes]; long[] after = new long[numberOfNodes]; for (int i = 0; i < numberOfNodes; i++) { afterCommon[i] = NumberOfRelationshipsMatching(label("Common"), withName("BAZ" + i), null); after[i] = NumberOfRelationshipsMatching(label("Foo" + i), withName("BAZ" + i), null); } // then for (int i = 0; i < numberOfNodes; i++) { assertEquals(beforeCommon[i] - 1, afterCommon[i]); assertEquals(before[i] - 1, after[i]); } }
public override void Perform(long nodeId, string value) { Node node = _db.getNodeById(nodeId); Label label = Label.label(value); if (node.HasLabel(label)) { node.RemoveLabel(label); } else { node.AddLabel(label); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldIdentifyTransactionWithNetZeroChangesAsReadOnly() public virtual void ShouldIdentifyTransactionWithNetZeroChangesAsReadOnly() { // GIVEN a transaction that has seen some changes, where all those changes result in a net 0 change set // a good way of producing such state is to add a label to an existing node, and then remove it. GraphDatabaseAPI db = Dbr.GraphDatabaseAPI; TransactionIdStore txIdStore = Db.DependencyResolver.resolveDependency(typeof(TransactionIdStore)); long startTxId = txIdStore.LastCommittedTransactionId; Node node = CreateEmptyNode(db); using (Transaction tx = Db.beginTx()) { node.AddLabel(TestLabels.LABEL_ONE); node.RemoveLabel(TestLabels.LABEL_ONE); tx.Success(); } // WHEN closing that transaction // THEN it should not have been committed assertEquals("Expected last txId to be what it started at + 2 (1 for the empty node, and one for the label)", startTxId + 2, txIdStore.LastCommittedTransactionId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDetectNoChangesInCommitsAlsoForTheIndexes() public virtual void ShouldDetectNoChangesInCommitsAlsoForTheIndexes() { // GIVEN a transaction that has seen some changes, where all those changes result in a net 0 change set // a good way of producing such state is to add a label to an existing node, and then remove it. GraphDatabaseAPI db = Dbr.GraphDatabaseAPI; TransactionIdStore txIdStore = Db.DependencyResolver.resolveDependency(typeof(TransactionIdStore)); long startTxId = txIdStore.LastCommittedTransactionId; Node node = CreateEmptyNode(db); Index <Node> index = CreateNodeIndex(db); using (Transaction tx = Db.beginTx()) { node.AddLabel(TestLabels.LABEL_ONE); node.RemoveLabel(TestLabels.LABEL_ONE); index.Add(node, "key", "value"); index.Remove(node, "key", "value"); tx.Success(); } // WHEN closing that transaction // THEN it should not have been committed assertEquals("Expected last txId to be what it started at + 3 " + "(1 for the empty node, 1 for index, and one for the label)", startTxId + 3, txIdStore.LastCommittedTransactionId); }