public void Test_UsingGivenDatabaseConnection_Insert() { //---------------Set up test pack------------------- BORegistry.DataAccessor = new DataAccessorInMemory(); MyBO.LoadDefaultClassDef(); MyBO bo = new MyBO(); DatabaseConnection.CurrentConnection = null; //---------------Assert preconditions--------------- Assert.AreNotSame(_databaseConnection, DatabaseConnection.CurrentConnection); //---------------Execute Test ---------------------- TransactionalBusinessObjectDB transactional = new TransactionalBusinessObjectDB(bo, _databaseConnection); SqlStatement sqlStatement = (SqlStatement)transactional.GetPersistSql().FirstOrDefault(); //---------------Test Result ----------------------- Assert.AreSame(_databaseConnection, sqlStatement.Connection); //---------------Tear down ------------------------- }
public void TestTransactionLogPersistsSQL_AddedToBusinessObjectPersistsSql() { //---------------Set up test pack------------------- //Create Mock Business object that implements a stub transaction log. ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging(); TransactionalBusinessObjectDB transactionalBODB = new TransactionalBusinessObjectDB(cp, DatabaseConnection.CurrentConnection); //---------------Assert Preconditions -------------- //---------------Execute Test ---------------------- var sqlStatementCollection = transactionalBODB.GetPersistSql(); //---------------Test Result ----------------------- //check if the transaction committer has 2 object // check that the one object is the transaction log object. var sqlStatements = sqlStatementCollection.ToList(); Assert.AreEqual(2, sqlStatements.Count); ISqlStatement sqlStatement = sqlStatements[1]; TransactionLogTable transactionLogTable = new TransactionLogTable(cp); Assert.AreEqual(transactionLogTable.GetPersistSql().First().Statement.ToString(), sqlStatement.Statement.ToString()); }
public void TestTransactionLogPersistsSQL_NotAddedToBusinessObjectPersistsSql_WhenObjectUnchanged() { //---------------Set up test pack------------------- //Create Mock Business object that implements a stub transaction log. ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging(); TransactionCommitterStub tc = new TransactionCommitterStub(); tc.AddBusinessObject(cp); tc.CommitTransaction(); TransactionalBusinessObjectDB transactionalBODB = new TransactionalBusinessObjectDB(cp, DatabaseConnection.CurrentConnection); //---------------Assert Preconditions -------------- //---------------Execute Test ---------------------- IEnumerable <ISqlStatement> sqlStatementCollection = transactionalBODB.GetPersistSql(); //---------------Test Result ----------------------- //check if the transaction committer has 2 object // check that the one object is the transaction log object. Assert.AreEqual(0, sqlStatementCollection.Count()); //ISqlStatement sqlStatement = sqlStatementCollection[1]; //TransactionLogTable transactionLogTable = new TransactionLogTable(cp); //Assert.AreEqual(transactionLogTable.GetPersistSql()[0].Statement.ToString(), sqlStatement.Statement.ToString()); }
protected override void ExecuteTransactionToDataSource(ITransactional transaction) { TransactionalBusinessObjectDB transactionDB = (TransactionalBusinessObjectDB)transaction; transactionDB.GetPersistSql(); }