public void VerifyRollbackUndoesChanges()
        {
            Transaction transaction = new EsentTransaction(this.session, "test", null);

            this.InsertRecord(1);
            transaction.Rollback();

            Assert.IsFalse(this.ContainsRecord(1));
        }
        public void VerifyRolledBackEventIsCalledOnRollback()
        {
            bool eventCalled = false;

            Transaction transaction = new EsentTransaction(this.session, "test", null);

            transaction.RolledBack += () => eventCalled = true;
            transaction.Rollback();

            Assert.IsTrue(eventCalled);
        }
        public void VerifyCommitThenRollbackUndoesChanges()
        {
            var         outerTransaction = new EsentTransaction(this.session, "test", null);
            Transaction innerTransaction = new EsentTransaction(this.session, "test", outerTransaction);

            this.InsertRecord(1);
            innerTransaction.Commit();
            Assert.IsTrue(this.ContainsRecord(1));

            outerTransaction.Rollback();
            Assert.IsFalse(this.ContainsRecord(1));
        }
        public void VerifyRollbackOfOuterTransactionRollsbackInnerTransaction()
        {
            bool eventCalled = false;

            var         outerTransaction = new EsentTransaction(this.session, "test", null);
            Transaction innerTransaction = new EsentTransaction(this.session, "test", outerTransaction);

            innerTransaction.RolledBack += () => eventCalled = true;
            outerTransaction.Rollback();

            Assert.IsTrue(eventCalled);
        }
        public void VerifyRolledBackEventMigratesToOuterTransactionOnCommit()
        {
            bool eventCalled = false;

            var         outerTransaction = new EsentTransaction(this.session, "test", null);
            Transaction innerTransaction = new EsentTransaction(this.session, "test", outerTransaction);

            innerTransaction.RolledBack += () => eventCalled = true;
            innerTransaction.Commit();
            outerTransaction.Rollback();

            Assert.IsTrue(eventCalled);
        }