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()); }