private int addNewEntity(string str, long lng)
 {
     using (var tx = Session.BeginTransaction())
     {
         var bte = new BasicTestEntity1 {
             Str1 = str, Long1 = lng
         };
         Session.Save(bte);
         tx.Commit();
         return(bte.Id);
     }
 }
        public void VerifyHistoryOf1()
        {
            var ver1 = new BasicTestEntity1 {
                Id = id1, Str1 = "x", Long1 = 1
            };
            var ver2 = new BasicTestEntity1 {
                Id = id1, Str1 = "x2", Long1 = 1
            };

            Assert.AreEqual(ver1, AuditReader().Find <BasicTestEntity1>(id1, 1));
            Assert.AreEqual(ver2, AuditReader().Find <BasicTestEntity1>(id1, 2));
            Assert.AreEqual(ver2, AuditReader().Find <BasicTestEntity1>(id1, 3));
        }
        public void VerifyHistoryOf3()
        {
            var ver1 = new BasicTestEntity1 {
                Id = id3, Str1 = "z", Long1 = 300
            };
            var ver2 = new BasicTestEntity1 {
                Id = id3, Str1 = "z3", Long1 = 300
            };

            Assert.IsNull(AuditReader().Find <BasicTestEntity1>(id3, 1));
            Assert.AreEqual(ver1, AuditReader().Find <BasicTestEntity1>(id3, 2));
            Assert.AreEqual(ver2, AuditReader().Find <BasicTestEntity1>(id3, 3));
        }
        public void VerifyHistoryOf2()
        {
            var ver1 = new BasicTestEntity1 {
                Id = id2, Long1 = 20
            };
            var ver2 = new BasicTestEntity1 {
                Id = id2, Str1 = "y2", Long1 = 20
            };

            Assert.IsNull(AuditReader().Find <BasicTestEntity1>(id2, 1));
            Assert.AreEqual(ver1, AuditReader().Find <BasicTestEntity1>(id2, 2));
            Assert.AreEqual(ver1, AuditReader().Find <BasicTestEntity1>(id2, 3));
            Assert.AreEqual(ver2, AuditReader().Find <BasicTestEntity1>(id2, 4));
        }
        protected override void Initialize()
        {
            var bte1 = new BasicTestEntity1 {
                Str1 = "x", Long1 = 1
            };
            var bte2 = new BasicTestEntity1 {
                Str1 = "y", Long1 = 20
            };
            var bte3 = new BasicTestEntity1 {
                Str1 = "z", Long1 = 300
            };

            //revision 1
            using (var tx = Session.BeginTransaction())
            {
                id1 = (int)Session.Save(bte1);
                id2 = (int)Session.Save(bte2);
                tx.Commit();
            }
            //revision 2
            using (var tx = Session.BeginTransaction())
            {
                id3        = (int)Session.Save(bte3);
                bte1.Str1  = "x2";
                bte2.Long1 = 21;
                tx.Commit();
            }
            //revision 3
            using (var tx = Session.BeginTransaction())
            {
                bte2.Str1  = "y3";
                bte2.Long1 = 22;
                bte3.Str1  = "z3";
                tx.Commit();
            }
        }