public void ExplicitTransaction9() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); ct.BeginCommit(null, null); ct.BeginCommit(null, null); }
public void ExplicitTransaction9() { Assert.Throws <InvalidOperationException>(() => { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); ct.BeginCommit(null, null); ct.BeginCommit(null, null); }); }
public void AsyncFail1() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; IAsyncResult ar = ct.BeginCommit(null, null); IAsyncResult ar2 = ct.BeginCommit(null, null); }
public void ExplicitTransaction13() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); Assert.IsNull(Transaction.Current); Transaction.Current = ct; irm.Value = 2; irm.FailPrepare = true; try { ct.Commit(); } catch (TransactionAbortedException) { Assert.AreEqual(TransactionStatus.Aborted, ct.TransactionInformation.Status); try { ct.BeginCommit(null, null); } catch (Exception) { Transaction.Current = null; return; } Assert.Fail("Should not be reached(2)"); } Assert.Fail("Should not be reached"); }
public void Async5() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; IAsyncResult ar = ct.BeginCommit(null, null); ar.AsyncWaitHandle.WaitOne(); Assert.IsTrue(ar.IsCompleted); try { CommittableTransaction ctx = ar as CommittableTransaction; ctx.EndCommit(ar); } catch (TransactionAbortedException) { irm.Check(1, 0, 0, 0, "irm"); return; } Assert.Fail("EndCommit should've failed"); }
public void AsyncFail3() { delayedException = null; IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; callback = new AsyncCallback(CommitCallback); IAsyncResult ar = ct.BeginCommit(callback, 5); mr.WaitOne(new TimeSpan(0, 0, 60)); Assert.IsTrue(called, "callback not called"); Assert.AreEqual(5, state, "state not preserved"); if (delayedException.GetType() != typeof(TransactionAbortedException)) { Assert.Fail("Expected TransactionAbortedException, got {0}", delayedException.GetType()); } }
public void Async2() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); using (TransactionScope scope = new TransactionScope(ct)) { irm.Value = 2; //scope.Complete (); IAsyncResult ar = ct.BeginCommit(null, null); try { ct.EndCommit(ar); } catch (TransactionAbortedException) { irm.Check(0, 0, 1, 0, "irm"); return; } } Assert.Fail("EndCommit should've thrown an exception"); }
private void OnBodyCompleted(NativeActivityContext context, System.Activities.ActivityInstance completedInstance) { TransactedReceiveData data = context.Properties.Find(TransactedReceiveData.TransactedReceiveDataExecutionPropertyName) as TransactedReceiveData; if (!this.isNested.Get(context)) { CommittableTransaction initiatingTransaction = data.InitiatingTransaction as CommittableTransaction; if (initiatingTransaction != null) { initiatingTransaction.BeginCommit(TransactionCommitAsyncCallback, initiatingTransaction); } else { (data.InitiatingTransaction as DependentTransaction).Complete(); } } else { DependentTransaction transaction3 = data.InitiatingTransaction as DependentTransaction; if (transaction3 != null) { transaction3.Complete(); } } }
public void ExplicitTransaction10b() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); Transaction.Current = ct; irm.Value = 2; Transaction.Current = null; TransactionScope scope = new TransactionScope(ct); Assert.AreEqual(ct, Transaction.Current, "ambient transaction"); //scope2.Complete (); //scope2.Dispose (); IAsyncResult ar = ct.BeginCommit(null, null); try { ct.EndCommit(ar); } catch (TransactionAbortedException) { irm.Check(0, 0, 1, 0, "irm"); Transaction.Current = null; return; } Transaction.Current = null; Assert.Fail(); }
public void AsyncFail1() { Assert.Throws <InvalidOperationException>(() => { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; IAsyncResult ar = ct.BeginCommit(null, null); IAsyncResult ar2 = ct.BeginCommit(null, null); }); }
public void AsyncFail1() { Assert.Throws<InvalidOperationException>(() => { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; IAsyncResult ar = ct.BeginCommit(null, null); IAsyncResult ar2 = ct.BeginCommit(null, null); }); }
public void ExplicitTransaction12() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); irm.FailPrepare = true; ct.BeginCommit(null, null); ct.EndCommit(null); }
public void ExplicitTransaction12() { AssertExtensions.Throws <ArgumentException>("asyncResult", () => { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); irm.FailPrepare = true; ct.BeginCommit(null, null); ct.EndCommit(null); }); }
public void ExplicitTransaction12() { ExceptionAssert.Throws <ArgumentException>( delegate { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); irm.FailPrepare = true; ct.BeginCommit(null, null); ct.EndCommit(null); }); }
public void AsyncFail2() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; IAsyncResult ar = ct.BeginCommit(null, null); ct.EndCommit(ar); }
public void Async2() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); using (TransactionScope scope = new TransactionScope(ct)) { irm.Value = 2; //scope.Complete (); IAsyncResult ar = ct.BeginCommit(null, null); Assert.Throws <TransactionAbortedException>(() => ct.EndCommit(ar)); irm.Check(0, 0, 1, 0, "irm"); } }
public void Async3() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; IAsyncResult ar = ct.BeginCommit(null, null); ct.EndCommit(ar); irm.Check(1, 1, 0, 0, "irm"); }
public void AsyncFail2() { Assert.Throws<TransactionAbortedException>(() => { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; IAsyncResult ar = ct.BeginCommit(null, null); ct.EndCommit(ar); }); }
public void Async4() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; IAsyncResult ar = ct.BeginCommit(null, null); ar.AsyncWaitHandle.WaitOne(); Assert.True(ar.IsCompleted); irm.Check(1, 1, 0, 0, "irm"); }
public void ExplicitTransaction14() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); Assert.Null(Transaction.Current); Transaction.Current = ct; try { irm.Value = 2; ct.Commit(); Assert.Equal(TransactionStatus.Committed, ct.TransactionInformation.Status); Assert.Throws <InvalidOperationException>(() => ct.BeginCommit(null, null)); } finally { Transaction.Current = null; } }
public void ExplicitTransaction10b() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); Transaction.Current = ct; try { irm.Value = 2; Transaction.Current = null; TransactionScope scope = new TransactionScope(ct); Assert.Equal(ct, Transaction.Current); IAsyncResult ar = ct.BeginCommit(null, null); Assert.Throws <TransactionAbortedException>(() => ct.EndCommit(ar)); irm.Check(0, 0, 1, 0, "irm"); } finally { Transaction.Current = null; } }
public void Async5() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; IAsyncResult ar = ct.BeginCommit(null, null); ar.AsyncWaitHandle.WaitOne(); Assert.True(ar.IsCompleted); CommittableTransaction ctx = ar as CommittableTransaction; Assert.Throws <TransactionAbortedException>(() => ctx.EndCommit(ar)); irm.Check(1, 0, 0, 0, "irm"); }
public void Async1() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; callback = new AsyncCallback(CommitCallback); IAsyncResult ar = ct.BeginCommit(callback, 5); mr.WaitOne(new TimeSpan(0, 2, 0), true); Assert.IsTrue(called, "callback not called"); Assert.AreEqual(5, state, "State not received back"); if (delayedException != null) { throw new Exception("", delayedException); } }
public void AsyncFail3() { s_delayedException = null; IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; _callback = new AsyncCallback(CommitCallback); IAsyncResult ar = ct.BeginCommit(_callback, 5); s_mr.WaitOne(new TimeSpan(0, 0, 60)); Assert.True(s_called, "callback not called"); Assert.Equal(5, s_state); Assert.IsType <TransactionAbortedException>(s_delayedException); }
public void Async1() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; _callback = new AsyncCallback(CommitCallback); IAsyncResult ar = ct.BeginCommit(_callback, 5); s_mr.WaitOne(new TimeSpan(0, 2, 0)); Assert.True(s_called, "callback not called"); Assert.Equal(5, s_state); if (s_delayedException != null) { throw new Exception("", s_delayedException); } }
public void Async4() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; IAsyncResult ar = ct.BeginCommit(null, null); ar.AsyncWaitHandle.WaitOne(); Assert.True(ar.IsCompleted); irm.Check(1, 1, 0, 0, "irm"); }
public void Async5() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; IAsyncResult ar = ct.BeginCommit(null, null); ar.AsyncWaitHandle.WaitOne(); Assert.True(ar.IsCompleted); CommittableTransaction ctx = ar as CommittableTransaction; Assert.Throws<TransactionAbortedException>(() => ctx.EndCommit(ar)); irm.Check(1, 0, 0, 0, "irm"); }
public void AsyncFail3() { s_delayedException = null; IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; irm.FailPrepare = true; _callback = new AsyncCallback(CommitCallback); IAsyncResult ar = ct.BeginCommit(_callback, 5); s_mr.WaitOne(new TimeSpan(0, 0, 60)); Assert.True(s_called, "callback not called"); Assert.Equal(5, s_state); Assert.IsType<TransactionAbortedException>(s_delayedException); }
public void ExplicitTransaction10b() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); Transaction.Current = ct; try { irm.Value = 2; Transaction.Current = null; TransactionScope scope = new TransactionScope(ct); Assert.Equal(ct, Transaction.Current); IAsyncResult ar = ct.BeginCommit(null, null); Assert.Throws<TransactionAbortedException>(() => ct.EndCommit(ar)); irm.Check(0, 0, 1, 0, "irm"); } finally { Transaction.Current = null; } }
public void ExplicitTransaction9() { Assert.Throws<InvalidOperationException>(() => { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); ct.BeginCommit(null, null); ct.BeginCommit(null, null); }); }
public void ExplicitTransaction14() { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); Assert.Null(Transaction.Current); Transaction.Current = ct; try { irm.Value = 2; ct.Commit(); Assert.Equal(TransactionStatus.Committed, ct.TransactionInformation.Status); Assert.Throws<InvalidOperationException>(() => ct.BeginCommit(null, null)); } finally { Transaction.Current = null; } }
public void Async3() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; IAsyncResult ar = ct.BeginCommit(null, null); ct.EndCommit(ar); irm.Check(1, 1, 0, 0, "irm"); }
public void ExplicitTransaction12() { Assert.Throws<ArgumentException>(() => { CommittableTransaction ct = new CommittableTransaction(); IntResourceManager irm = new IntResourceManager(1); irm.FailPrepare = true; ct.BeginCommit(null, null); ct.EndCommit(null); }); }
public void Async1() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); /* Set ambient Tx */ Transaction.Current = ct; /* Enlist */ irm.Value = 2; _callback = new AsyncCallback(CommitCallback); IAsyncResult ar = ct.BeginCommit(_callback, 5); s_mr.WaitOne(new TimeSpan(0, 2, 0)); Assert.True(s_called, "callback not called"); Assert.Equal(5, s_state); if (s_delayedException != null) throw new Exception("", s_delayedException); }
public void Async2() { IntResourceManager irm = new IntResourceManager(1); CommittableTransaction ct = new CommittableTransaction(); using (TransactionScope scope = new TransactionScope(ct)) { irm.Value = 2; //scope.Complete (); IAsyncResult ar = ct.BeginCommit(null, null); Assert.Throws<TransactionAbortedException>(() => ct.EndCommit(ar)); irm.Check(0, 0, 1, 0, "irm"); } }