public bool IgnoreSPC = false;
public bool FailSPC = false;
public bool FailCommit = false;
+ public bool FailRollback = false;
public bool UseSingle = false;
+ public Exception ThrowThisException = null;
Guid guid;
Assert.AreEqual ( c, NumCommit, msg + ": NumCommit" );
Assert.AreEqual ( r, NumRollback, msg + ": NumRollback" );
Assert.AreEqual ( d, NumInDoubt, msg + ": NumInDoubt" );
- Assert.AreEqual ( i, NumInitialize, msg + ": NumRollback" );
- Assert.AreEqual ( pr, NumPromote, msg + ": NumInDoubt" );
+ Assert.AreEqual ( i, NumInitialize, msg + ": NumInitialize" );
+ Assert.AreEqual ( pr, NumPromote, msg + ": NumPromote" );
}
/* Used for volatile RMs */
if ( resource.FailPrepare ) {
if (resource.FailWithException)
- preparingEnlistment.ForceRollback ( new NotSupportedException () );
+ preparingEnlistment.ForceRollback ( resource.ThrowThisException ?? new NotSupportedException () );
else
preparingEnlistment.ForceRollback ();
} else {
public void Commit ( Enlistment enlistment )
{
resource.NumCommit++;
- if ( resource.FailCommit )
- return;
+ if (resource.FailCommit)
+ {
+ if (resource.FailWithException)
+ throw (resource.ThrowThisException ?? new NotSupportedException());
+ else
+ return;
+ }
resource.Commit ();
enlistment.Done ();
public void Rollback ( Enlistment enlistment )
{
resource.NumRollback++;
+ if (resource.FailRollback)
+ {
+ if (resource.FailWithException)
+ throw (resource.ThrowThisException ?? new NotSupportedException());
+ else
+ return;
+ }
+
resource.Rollback ();
}
if ( resource.FailSPC ) {
if ( resource.FailWithException )
- enlistment.Aborted ( new NotSupportedException () );
+ enlistment.Aborted ( resource.ThrowThisException ?? new NotSupportedException () );
else
enlistment.Aborted ();
}