public async Task SessionIsDirtyShouldNotTriggerCascadeSavingAsync(bool beginTransaction) { Sfi.Statistics.IsStatisticsEnabled = true; using (var session = OpenSession()) using (beginTransaction ? session.BeginTransaction() : null) { var parent = await(GetParentAsync(session)); var entityChild = new EntityChild { Name = "NewListElem" }; //parent.Children is cascaded parent.Children.Add(entityChild); Sfi.Statistics.Clear(); var isDirty = await(session.IsDirtyAsync()); Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(0), "Dirty has triggered an insert"); Assert.That(isDirty, "ISession.IsDirty() call should return true."); if (Dialect.SupportsIdentityColumns) { Assert.That( entityChild.Id, Is.EqualTo(0), "Transient objects should not be saved by ISession.IsDirty() call (expected 0 as Id)"); } } }
public void SessionIsDirtyShouldNotTriggerCascadeSaving() { Sfi.Statistics.IsStatisticsEnabled = true; using (var session = OpenSession()) using (session.BeginTransaction()) { var parent = GetParent(session); var entityChild = new EntityChild { Name = "NewListElem" }; //parent.Children is cascaded parent.Children.Add(entityChild); Sfi.Statistics.Clear(); var isDirty = session.IsDirty(); Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(0), "Dirty has triggered an insert"); Assert.That( entityChild.Id, Is.EqualTo(0), "Transient objects should not be saved by ISession.IsDirty() call (expected 0 as Id)"); Assert.That(isDirty, "ISession.IsDirty() call should return true."); } }