public void When_removing_the_last_child_the_parent_should_not_be_valid() { var p = new TheParent("x"); p.AddChild(new TheChild("kik")); using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.SaveOrUpdate(p); tx.Commit(); } TheParent loadedParent; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { loadedParent = s.CreateQuery("from TheParent p where p.Name = 'x'") .UniqueResult<TheParent>(); loadedParent.Children.Should().Not.Be.Empty(); loadedParent.ClearChildren(); // This currently passes. Assert.False(vtor.IsValid(loadedParent)); // this currently fails. tx.Executing(t => t.Commit()).Throws<InvalidStateException>(); } }
public void When_removing_the_last_child_the_parent_should_not_be_valid() { var p = new TheParent("x"); p.AddChild(new TheChild("kik")); using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.SaveOrUpdate(p); tx.Commit(); } TheParent loadedParent; using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) { loadedParent = s.CreateQuery("from TheParent p where p.Name = 'x'") .UniqueResult <TheParent>(); loadedParent.Children.Should().Not.Be.Empty(); loadedParent.ClearChildren(); // This currently passes. Assert.False(vtor.IsValid(loadedParent)); // this currently fails. tx.Executing(t => t.Commit()).Throws <InvalidStateException>(); } }