public void RMFail1()
{
IntResourceManager irm = new IntResourceManager(1);
IntResourceManager irm2 = new IntResourceManager(10);
IntResourceManager irm3 = new IntResourceManager(12);
Assert.Null(Transaction.Current);
try
{
using (TransactionScope scope = new TransactionScope())
{
irm.Value = 2;
irm2.Value = 20;
irm3.Value = 24;
/* Make second RM fail to prepare, this should throw
* TransactionAbortedException when the scope ends
*/
irm2.FailPrepare = true;
scope.Complete();
}
}
catch (TransactionAbortedException)
{
irm.Check(1, 0, 1, 0, "irm");
irm2.Check(1, 0, 0, 0, "irm2");
irm3.Check(0, 0, 1, 0, "irm3");
}
Assert.Null(Transaction.Current);
}