Ejemplo n.º 1
0
        public void TestDBAccess_CheckRunningDBTransactionIsolationLevelIsCompatible_WithMinimumIsolationLevel_ExpectTrue()
        {
            bool      NewTrans;
            bool      Result;
            TDataBase db = DBAccess.Connect("TestDBAccess", FDataBase);

            //
            // Arrange
            //

            TDBTransaction transaction = db.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, out NewTrans);

            // Guard Assert: Check that the new DB Transaction has been taken out
            Assert.That(NewTrans, Is.True);

            // Act
            Result = db.CheckRunningDBTransactionIsolationLevelIsCompatible(IsolationLevel.ReadCommitted);

            // Primary Assert
            Assert.IsTrue(Result, "Calling CheckRunningDBTransactionIsolationLevelIsCompatible and asking for a minimum " +
                          "IsolationLevel that is met by the running DB Transactions' IsolationLevel did not return true");

            // Roll back the one DB Transaction that has been requested (this would happen automatically on DB closing, but
            // it's better to do this explicitly here so it is clear it isn't forgotten about.
            transaction.Rollback();
        }
Ejemplo n.º 2
0
        public void TestDBAccess_CheckRunningDBTransactionIsolationLevelIsCompatible_ExpectEDBNullTransactionException()
        {
            TDataBase db = DBAccess.Connect("TestDBAccess", FDataBase);

            // Guard Assert
            Assert.IsNull(db.Transaction);


            // Act/Assert
            Assert.Catch <EDBNullTransactionException>(delegate
            {
                db.CheckRunningDBTransactionIsolationLevelIsCompatible(
                    IsolationLevel.ReadCommitted);
            },
                                                       "Calling CheckRunningDBTransactionIsolationLevelIsCompatible and asking for an exact " +
                                                       "IsolationLevel that is exactly what the running DB Transaction has got did not throw EDBNullTransactionException");
        }