public void VerifyHistoryOfIng1() { var ed1_fromRev1 = new ListJoinColumnBidirectionalRefEdEntity { Id = ed1_id, Data = "ed1" }; var ed1_fromRev3 = new ListJoinColumnBidirectionalRefEdEntity { Id = ed1_id, Data = "ed1 bis" }; var ed2 = Session.Get <ListJoinColumnBidirectionalRefEdEntity>(ed2_id); var rev1 = AuditReader().Find <ListJoinColumnBidirectionalRefIngEntity>(ing1_id, 1); var rev2 = AuditReader().Find <ListJoinColumnBidirectionalRefIngEntity>(ing1_id, 2); var rev3 = AuditReader().Find <ListJoinColumnBidirectionalRefIngEntity>(ing1_id, 3); var rev4 = AuditReader().Find <ListJoinColumnBidirectionalRefIngEntity>(ing1_id, 4); rev1.References.Should().Have.SameValuesAs(ed1_fromRev1); rev2.References.Should().Have.SameValuesAs(ed1_fromRev1, ed2); rev3.References.Should().Have.SameValuesAs(ed1_fromRev3, ed2); rev4.References.Should().Be.Empty(); }
protected override void Initialize() { // Revision 1 (ing1: ed1, ing2: ed2) using (var tx = Session.BeginTransaction()) { var ed1 = new ListJoinColumnBidirectionalRefEdEntity { Data = "ed1" }; var ed2 = new ListJoinColumnBidirectionalRefEdEntity { Data = "ed2" }; var ing1 = new ListJoinColumnBidirectionalRefIngEntity { Data = "coll1", References = new List <ListJoinColumnBidirectionalRefEdEntity> { ed1 } }; var ing2 = new ListJoinColumnBidirectionalRefIngEntity { Data = "coll1", References = new List <ListJoinColumnBidirectionalRefEdEntity> { ed2 } }; ed1_id = (int)Session.Save(ed1); ed2_id = (int)Session.Save(ed2); ing1_id = (int)Session.Save(ing1); ing2_id = (int)Session.Save(ing2); tx.Commit(); Session.Clear(); } // Revision 2 (ing1: ed1, ed2) using (var tx = Session.BeginTransaction()) { var ing1 = Session.Get <ListJoinColumnBidirectionalRefIngEntity>(ing1_id); var ing2 = Session.Get <ListJoinColumnBidirectionalRefIngEntity>(ing2_id); var ed2 = Session.Get <ListJoinColumnBidirectionalRefEdEntity>(ed2_id); ing2.References.Remove(ed2); ing1.References.Add(ed2); tx.Commit(); Session.Clear(); } // No revision - no changes using (var tx = Session.BeginTransaction()) { var ing2 = Session.Get <ListJoinColumnBidirectionalRefIngEntity>(ing2_id); var ed1 = Session.Get <ListJoinColumnBidirectionalRefEdEntity>(ed1_id); ed1.Data = "ed1 bis"; // Shouldn't get written ed1.Owner = ing2; tx.Commit(); Session.Clear(); } // Revision 4 (ing2: ed1, ed2) using (var tx = Session.BeginTransaction()) { var ing1 = Session.Get <ListJoinColumnBidirectionalRefIngEntity>(ing1_id); var ing2 = Session.Get <ListJoinColumnBidirectionalRefIngEntity>(ing2_id); var ed1 = Session.Get <ListJoinColumnBidirectionalRefEdEntity>(ed1_id); var ed2 = Session.Get <ListJoinColumnBidirectionalRefEdEntity>(ed2_id); ing1.References.Clear(); ing2.References.Add(ed1); ing2.References.Add(ed2); tx.Commit(); } }