protected override void OnSetUp() { using (ISession session = OpenSession()) using (ITransaction tx = session.BeginTransaction()) { var parent = new Parent(); var childOne = new Child(); parent.Childs.Add(childOne); session.Save(parent); tx.Commit(); } }
public void DisposedCommandShouldNotBeReusedAfterClearAndAdd() { using (ISession session = OpenSession()) using (ITransaction tx = session.BeginTransaction()) { var parent = session.CreateCriteria<Parent>().UniqueResult<Parent>(); parent.Childs.Clear(); var childOne = new Child(); parent.Childs.Add(childOne); var childTwo = new Child(); parent.Childs.Add(childTwo); Assert.DoesNotThrow(tx.Commit); Assert.That(childOne.Id, Is.EqualTo(parent.Childs[0].Id)); Assert.That(childTwo.Id, Is.EqualTo(parent.Childs[1].Id)); } }
public void DisposedCommandShouldNotBeReusedAfterRemoveAtAndInsert() { using (ISession session = OpenSession()) using (ITransaction tx = session.BeginTransaction()) { var parent = session.CreateCriteria<Parent>().UniqueResult<Parent>(); Child childOne = parent.Childs[0]; var childTwo = new Child(); parent.Childs.Add(childTwo); Child childToMove = parent.Childs[1]; parent.Childs.RemoveAt(1); parent.Childs.Insert(0, childToMove); Assert.DoesNotThrow(tx.Commit); Assert.AreEqual(childTwo.Id, parent.Childs[0].Id); Assert.AreEqual(childOne.Id, parent.Childs[1].Id); } }