public void TestRaisesException_onError()
 {
     //---------------Set up test pack-------------------
     TransactionCommitter committerDB = new TransactionCommitterStubDB(DatabaseConnection.CurrentConnection);
     StubFailingTransaction trn = new StubFailingTransaction();
     committerDB.AddTransaction(trn);
     committerDB.AddTransaction(new StubSuccessfullTransaction());
     //---------------Execute Test ----------------------
     try
     {
         committerDB.CommitTransaction();
         Assert.Fail("Expected to throw an NotImplementedException");
     }
         //---------------Test Result -----------------------
     catch (NotImplementedException)
     {
     }
 }
 public void TestRaisesException_onError_DoesNotCommit()
 {
     //---------------Set up test pack-------------------
     TransactionCommitter committer = new TransactionCommitterStubDB(DatabaseConnection.CurrentConnection);
     StubDatabaseTransaction transactional1 = new StubDatabaseTransaction();
     committer.AddTransaction(transactional1);
     StubFailingTransaction transactional2 = new StubFailingTransaction();
     committer.AddTransaction(transactional2);
     //---------------Execute Test ----------------------
     try
     {
         committer.CommitTransaction();
         Assert.Fail("Failure should have occurred as a StubFailingTransaction was added");
     }
     //---------------Test Result -----------------------
     catch (NotImplementedException)
     {
         Assert.IsFalse(transactional1.Committed);
         Assert.IsFalse(transactional2.Committed);
     }
 }
 public void TestRollBack_OnError()
 {
     //---------------Set up test pack-------------------
     //Create object in DB
     MockBoWithRollBack mockBo = new MockBoWithRollBack();
     StubDatabaseFailureTransaction trnFail = new StubDatabaseFailureTransaction();
     TransactionCommitterStubDB trnCommitter = new TransactionCommitterStubDB(DatabaseConnection.CurrentConnection);
     trnCommitter.AddBusinessObject(mockBo);
     trnCommitter.AddTransaction(trnFail);
     Assert.IsFalse(mockBo.RollBackExecuted);
     //---------------Execute Test ----------------------
     try
     {
         trnCommitter.CommitTransaction();
         Assert.Fail();
     }
         //---------------Test Result -----------------------
         //Raise Exception that the object has been edited since 
         // the user last edited.
     catch (NotImplementedException)
     {
         Assert.IsTrue(mockBo.RollBackExecuted);
     }
 }