コード例 #1
0
 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)
     {
     }
 }
コード例 #2
0
 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);
     }
 }