public void TestNotCalledByBusinessObjectInUpdateObjectBeforePersisting_Deleted() { //-------------Setup Test Pack ------------------ TransactionCommitterStub transactionCommitterStub = new TransactionCommitterStub(); MyBusinessObjectUpdateLogBo myBusinessObjectUpdateLogBo = new MyBusinessObjectUpdateLogBo(); transactionCommitterStub.AddBusinessObject(myBusinessObjectUpdateLogBo); transactionCommitterStub.CommitTransaction(); BusinessObjectUpdateLogStub businessObjectUpdateLog = myBusinessObjectUpdateLogBo.BusinessObjectUpdateLog as BusinessObjectUpdateLogStub; myBusinessObjectUpdateLogBo.MarkForDelete(); transactionCommitterStub = new TransactionCommitterStub(); transactionCommitterStub.AddBusinessObject(myBusinessObjectUpdateLogBo); //-------------Test Pre-conditions -------------- Assert.IsFalse(myBusinessObjectUpdateLogBo.Status.IsNew, "BusinessObject should not be new"); Assert.IsTrue(myBusinessObjectUpdateLogBo.Status.IsDeleted, "BusinessObject should be deleted"); Assert.IsNotNull(businessObjectUpdateLog); businessObjectUpdateLog.Called = false; //-------------Execute test --------------------- myBusinessObjectUpdateLogBo.UpdateObjectBeforePersisting(transactionCommitterStub); //-------------Test Result ---------------------- Assert.IsFalse(businessObjectUpdateLog.Called, "BusinessObject Update Log should have been called upon persisting."); }
public void TestTransactionLogTransactionNotAddedToTransactionCommitter() { //---------------Set up test pack------------------- //Create Mock Business object that implements a stub transaction log. ContactPersonTransactionLogging cp = CreateUnsavedContactPersonTransactionLogging(); TransactionCommitterStub tc = new TransactionCommitterStub(); tc.AddBusinessObject(cp); Assert.AreEqual(1, tc.OriginalTransactions.Count); //---------------Execute Test ---------------------- //call persist on the object tc.CommitTransaction(); //---------------Test Result ----------------------- //check that the transaction committer has 1 object // i.e. the transaction log object was not added to the transaction. Assert.AreEqual(1, tc.ExecutedTransactions.Count); }