When i run this test using TestDriven.net it passes, but with nunit gui it fails. all other test run fine. do you have any ideas:
test:
[Test]
public void RollbackTransactionSucceed()
{
MockManager.Init();
MockObject dbTransactionObjMock = MockManager.MockObject(typeof(DbTransaction));
DbTransaction dbTransaction = (DbTransaction)dbTransactionObjMock.Object;
dbTransactionObjMock.ExpectAndThrow("Commit", new Exception("error"), 1);
dbTransactionObjMock.ExpectCall("Rollback",1);
BaseDal dal = new UserDal();
dal.Transaction = dbTransaction;
bool returnValue = dal.CommitTransaction();
Assert.IsFalse(returnValue);
MockManager.Verify();
}
method:
public bool CommitTransaction()
{
bool committed = false;
try
{
dbTransaction.Commit();
committed = true;
}
catch(Exception)
{
dbTransaction.Rollback();
}
return committed;
}
the error in nunit is:
...RollbackTransactionSucceed : TypeMock.VerifyException :
TypeMock Verification: Method MockDbTransaction.Rollback() has 1 more expected calls