public static void TestCase_BlockingCloneCompletedAfterCommit(bool promote)
{
string testCaseDescription = string.Format(
"TestCase_BlockingCloneCompletedAfterCommit promote={0}",
promote
);
Trace("**** " + testCaseDescription + " ****");
AutoResetEvent pspeCompleted = new AutoResetEvent(false);
NonMSDTCPromoterEnlistment pspe = null;
NoStressTrace(string.Format("There will be a 2 second delay here - {0}", DateTime.Now.ToString()));
try
{
using (TransactionScope ts = new TransactionScope())
{
DependentTransaction clone = CreateDependentClone(/*blocking=*/true);
Task.Run(() => CompleteDependentCloneThread(clone));
pspe = (NonMSDTCPromoterEnlistment)CreatePSPEEnlistment(NonMsdtcPromoterTests.PromoterType1,
NonMsdtcPromoterTests.PromotedToken1,
pspeCompleted,
/*nonMSDTC = */ true,
/*tx = */ null,
/*spcResponse=*/ TransactionStatus.Committed,
/*expectRejection=*/ false
);
if (promote)
{
Promote(testCaseDescription, NonMsdtcPromoterTests.PromotedToken1);
}
ts.Complete();
}
}
catch (Exception ex)
{
Assert.Null(ex);
}
Assert.True(pspeCompleted.WaitOne(TimeSpan.FromSeconds(2)));
if (promote)
{
Assert.True(pspe.Promoted);
}
else
{
Assert.False(pspe.Promoted);
}
Assert.False(pspe.Aborted);
TestPassed(true);
}