public void MergeTree() { ClearCounts(); ISession s = OpenSession(); ITransaction tx = s.BeginTransaction(); var root = new Node { Name = "root" }; var child = new Node { Name = "child" }; root.AddChild(child); s.Persist(root); tx.Commit(); s.Close(); AssertInsertCount(2); ClearCounts(); root.Description = "The root node"; child.Description = "The child node"; var secondChild = new Node { Name = "second child" }; root.AddChild(secondChild); s = OpenSession(); tx = s.BeginTransaction(); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(1); AssertUpdateCount(2); }
public void MergeDeepTree() { ClearCounts(); ISession s = OpenSession(); ITransaction tx = s.BeginTransaction(); var root = new Node { Name = "root" }; var child = new Node { Name = "child" }; var grandchild = new Node { Name = "grandchild" }; root.AddChild(child); child.AddChild(grandchild); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(3); AssertUpdateCount(0); ClearCounts(); grandchild.Description = "the grand child"; var grandchild2 = new Node { Name = "grandchild2" }; child.AddChild(grandchild2); s = OpenSession(); tx = s.BeginTransaction(); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(1); AssertUpdateCount(1); ClearCounts(); var child2 = new Node { Name = "child2" }; var grandchild3 = new Node { Name = "grandchild3" }; child2.AddChild(grandchild3); root.AddChild(child2); s = OpenSession(); tx = s.BeginTransaction(); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(2); AssertUpdateCount(0); ClearCounts(); s = OpenSession(); tx = s.BeginTransaction(); s.Delete(grandchild); s.Delete(grandchild2); s.Delete(grandchild3); s.Delete(child); s.Delete(child2); s.Delete(root); tx.Commit(); s.Close(); }
public void MergeDeepTree() { ClearCounts(); var root = new Node { Created = RoundForDialect(DateTime.Now), Name = "root" }; var child = new Node { Created = RoundForDialect(DateTime.Now), Name = "child" }; var grandchild = new Node { Created = RoundForDialect(DateTime.Now), Name = "grandchild" }; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { root.AddChild(child); child.AddChild(grandchild); s.Merge(root); tx.Commit(); } AssertInsertCount(3); AssertUpdateCount(0); ClearCounts(); grandchild.Description = "the grand child"; var grandchild2 = new Node { Created = RoundForDialect(DateTime.Now), Name = "grandchild2" }; child.AddChild(grandchild2); using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { s.Merge(root); tx.Commit(); } AssertInsertCount(1); AssertUpdateCount(1); ClearCounts(); var child2 = new Node { Created = RoundForDialect(DateTime.Now), Name = "child2" }; var grandchild3 = new Node { Created = RoundForDialect(DateTime.Now), Name = "grandchild3" }; child2.AddChild(grandchild3); root.AddChild(child2); using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { s.Merge(root); tx.Commit(); } AssertInsertCount(2); AssertUpdateCount(0); ClearCounts(); using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { s.Delete(grandchild); s.Delete(grandchild2); s.Delete(grandchild3); s.Delete(child); s.Delete(child2); s.Delete(root); tx.Commit(); } }
public void MergeTree() { ClearCounts(); ISession s = OpenSession(); ITransaction tx = s.BeginTransaction(); var root = new Node {Name = "root"}; var child = new Node {Name = "child"}; root.AddChild(child); s.Persist(root); tx.Commit(); s.Close(); AssertInsertCount(2); ClearCounts(); root.Description = "The root node"; child.Description = "The child node"; var secondChild = new Node {Name = "second child"}; root.AddChild(secondChild); s = OpenSession(); tx = s.BeginTransaction(); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(1); AssertUpdateCount(2); }
public void MergeDeepTree() { ClearCounts(); ISession s = OpenSession(); ITransaction tx = s.BeginTransaction(); var root = new Node {Name = "root"}; var child = new Node {Name = "child"}; var grandchild = new Node {Name = "grandchild"}; root.AddChild(child); child.AddChild(grandchild); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(3); AssertUpdateCount(0); ClearCounts(); grandchild.Description = "the grand child"; var grandchild2 = new Node {Name = "grandchild2"}; child.AddChild(grandchild2); s = OpenSession(); tx = s.BeginTransaction(); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(1); AssertUpdateCount(1); ClearCounts(); var child2 = new Node {Name = "child2"}; var grandchild3 = new Node {Name = "grandchild3"}; child2.AddChild(grandchild3); root.AddChild(child2); s = OpenSession(); tx = s.BeginTransaction(); s.Merge(root); tx.Commit(); s.Close(); AssertInsertCount(2); AssertUpdateCount(0); ClearCounts(); s = OpenSession(); tx = s.BeginTransaction(); s.Delete(grandchild); s.Delete(grandchild2); s.Delete(grandchild3); s.Delete(child); s.Delete(child2); s.Delete(root); tx.Commit(); s.Close(); }
public async Task MergeDeepTreeAsync() { ClearCounts(); var root = new Node { Name = "root" }; var child = new Node { Name = "child" }; var grandchild = new Node { Name = "grandchild" }; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { root.AddChild(child); child.AddChild(grandchild); await(s.MergeAsync(root)); await(tx.CommitAsync()); } AssertInsertCount(3); AssertUpdateCount(0); ClearCounts(); grandchild.Description = "the grand child"; var grandchild2 = new Node { Name = "grandchild2" }; child.AddChild(grandchild2); using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { await(s.MergeAsync(root)); await(tx.CommitAsync()); } AssertInsertCount(1); AssertUpdateCount(1); ClearCounts(); var child2 = new Node { Name = "child2" }; var grandchild3 = new Node { Name = "grandchild3" }; child2.AddChild(grandchild3); root.AddChild(child2); using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { await(s.MergeAsync(root)); await(tx.CommitAsync()); } AssertInsertCount(2); AssertUpdateCount(0); ClearCounts(); using (var s = OpenSession()) using (var tx = s.BeginTransaction()) { await(s.DeleteAsync(grandchild)); await(s.DeleteAsync(grandchild2)); await(s.DeleteAsync(grandchild3)); await(s.DeleteAsync(child)); await(s.DeleteAsync(child2)); await(s.DeleteAsync(root)); await(tx.CommitAsync()); } }