protected override void Initialize()
        {
            var ite1 = new IntTestEntity {
                Number = 12
            };
            var ite2 = new IntTestEntity {
                Number = 5
            };
            var ite3 = new IntTestEntity {
                Number = 8
            };
            var ite4 = new IntTestEntity {
                Number = 1
            };
            var ite5 = new IntTestEntity {
                Number = 3
            };

            using (var tx = Session.BeginTransaction())
            {
                id1 = (int)Session.Save(ite1);
                id2 = (int)Session.Save(ite2);
                id3 = (int)Session.Save(ite3);
                id4 = (int)Session.Save(ite4);
                tx.Commit();
            }

            using (var tx = Session.BeginTransaction())
            {
                id5         = (int)Session.Save(ite5);
                ite1.Number = 0;
                ite4.Number = 15;
                tx.Commit();
            }
        }
        protected override void Initialize()
        {
            var ite1 = new IntTestEntity {
                Number = 2
            };
            var ite2 = new IntTestEntity {
                Number = 10
            };
            var ite3 = new IntTestEntity {
                Number = 8
            };
            var uine1 = new UnusualIdNamingEntity {
                UniqueField = "Id1", VariousData = "data1"
            };

            using (var tx = Session.BeginTransaction())
            {
                Session.Save(ite1);
                Session.Save(ite2);
                tx.Commit();
            }
            using (var tx = Session.BeginTransaction())
            {
                Session.Save(ite3);
                Session.Save(uine1);
                ite1.Number = 0;
                tx.Commit();
            }
            using (var tx = Session.BeginTransaction())
            {
                ite2.Number = 52;
                tx.Commit();
            }
        }
Example #3
0
        public void VerifyHistory()
        {
            var ver1 = new IntTestEntity {
                Id = id1, Number = 10
            };
            var ver2 = new IntTestEntity {
                Id = id1, Number = 20
            };

            Assert.AreEqual(ver1, AuditReader().Find <IntTestEntity>(id1, 1));
            Assert.AreEqual(ver2, AuditReader().Find(typeof(IntTestEntity), id1, 2));
        }
        public void WhenAuditPersistExceptionOccursTransactionShouldBeRolledBack()
        {
            int intId;
            var willCrash = new NoSchemaEntity();
            var intEntity = new IntTestEntity();

            using (var tx = Session.BeginTransaction())
            {
                intId = (int)Session.Save(intEntity);
                Session.Save(willCrash);
                Assert.Throws <GenericADOException>(tx.Commit);
            }
            ForceNewSession();
            verifyNoDataGotPeristed(intId);
        }
        public void WhenAuditPersistExceptionOccursTransactionShouldBeRolledBack_FlushModeNever()
        {
            int intId;
            var willCrash = new NoSchemaEntity();
            var intEntity = new IntTestEntity();

            Session.FlushMode = FlushMode.Never;

            using (Session.BeginTransaction())
            {
                intId = (int)Session.Save(intEntity);
                Session.Save(willCrash);
                Assert.Throws <GenericADOException>(Session.Flush);
            }
            verifyNoDataGotPeristed(intId);
        }
Example #6
0
        protected override void Initialize()
        {
            var ite = new IntTestEntity {
                Number = 10
            };

            using (var tx = Session.BeginTransaction())
            {
                id1 = (int)Session.Save(ite);
                tx.Commit();
            }
            using (var tx = Session.BeginTransaction())
            {
                ite.Number = 20;
                tx.Commit();
            }
        }
Example #7
0
        protected override void Initialize()
        {
            var entity = new IntTestEntity {
                Number = 10
            };

            using (var tx = new TransactionScope())
            {
                id = (int)Session.Save(entity);
                tx.Complete();
            }
            using (var tx = new TransactionScope())
            {
                entity.Number = 20;
                tx.Complete();
            }
        }
 protected override void Initialize()
 {
     using (var tx = Session.BeginTransaction())
     {
         var iteRollback = new IntTestEntity {
             Number = 30
         };
         rollbackId = (int)Session.Save(iteRollback);
         tx.Rollback();
     }
     using (var tx = Session.BeginTransaction())
     {
         var iteCommitted = new IntTestEntity {
             Number = 50
         };
         committedId = (int)Session.Save(iteCommitted);
         tx.Commit();
     }
 }