diff --git a/src/DocumentDbTests/SessionMechanics/dirty_tracked_sessions.cs b/src/DocumentDbTests/SessionMechanics/dirty_tracked_sessions.cs index aaa1bfc21b..4d8e92ce4d 100644 --- a/src/DocumentDbTests/SessionMechanics/dirty_tracked_sessions.cs +++ b/src/DocumentDbTests/SessionMechanics/dirty_tracked_sessions.cs @@ -117,4 +117,45 @@ public void store_reload_update_and_delete_by_id_in_same_dirty_tracked_session() var user3 = query.Load(user.Id); user3.ShouldBeNull(); } + + [Fact] + public void store_reload_delete_reload_and_update_document_in_same_dirty_tracked_session() + { + var user = new User { FirstName = "James", LastName = "Worthy" }; + + using var session = theStore.DirtyTrackedSession(); + session.Store(user); + session.SaveChanges(); + + var user2 = session.Load(user.Id); + user2.FirstName = "Jens"; + session.Delete(user2); + user2 = session.Load(user.Id); + user2.FirstName = "Jens"; + session.SaveChanges(); + + using var query = theStore.QuerySession(); + var user3 = query.Load(user.Id); + user3.FirstName.ShouldBe("Jens"); + } + + [Fact] + public void store_reload_update_and_eject_document_in_same_dirty_tracked_session() + { + var user = new User { FirstName = "James", LastName = "Worthy" }; + + using var session = theStore.DirtyTrackedSession(); + session.Store(user); + session.SaveChanges(); + + var user2 = session.Load(user.Id); + user2.FirstName = "Jens"; + session.Eject(user2); + session.SaveChanges(); + + using var query = theStore.QuerySession(); + var user3 = query.Load(user.Id); + user3.FirstName.ShouldBe("James"); + } + }