Skip to content

Commit

Permalink
Add some more tests for dirty tracked sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
e-tobi committed Jul 28, 2024
1 parent 4de127e commit add8bce
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/DocumentDbTests/SessionMechanics/dirty_tracked_sessions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,45 @@ public void store_reload_update_and_delete_by_id_in_same_dirty_tracked_session()
var user3 = query.Load<User>(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>(user.Id);
user2.FirstName = "Jens";
session.Delete(user2);
user2 = session.Load<User>(user.Id);
user2.FirstName = "Jens";
session.SaveChanges();

using var query = theStore.QuerySession();
var user3 = query.Load<User>(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>(user.Id);
user2.FirstName = "Jens";
session.Eject(user2);
session.SaveChanges();

using var query = theStore.QuerySession();
var user3 = query.Load<User>(user.Id);
user3.FirstName.ShouldBe("James");
}

}

0 comments on commit add8bce

Please sign in to comment.