public GetExpectedCommitState ( ) : TransactionContextState | ||
return | TransactionContextState |
private static async Task ExecuteNode(TransactionContextTestNode node) { if (node.Parent == null) { Assert.That(TransactionContext.CurrentTransactionContext, Is.Null); } var tcs = new TaskCompletionSource <TransactionContextState>(); using (var tx = new TransactionContext(node.Affinity)) { Assert.That(TransactionContext.CurrentTransactionContext, Is.EqualTo(tx)); Assert.That(tx.IsController, Is.EqualTo(node.IsController)); if (node.IsController) { tx.StateChanged += (s, e) => { if (e.NewState == TransactionContextState.Exited) { tcs.SetResult(e.OldState); } }; } await node.ExecuteOperation().ConfigureAwait(false); if (node.Children != null) { foreach (var child in node.Children) { await ExecuteNode(child).ConfigureAwait(false); } } if (node.VoteAction == VoteAction.VoteCommit) { tx.VoteCommit(); } else if (node.VoteAction == VoteAction.VoteRollback) { tx.VoteRollback(); } } if (node.Parent == null) { Assert.That(TransactionContext.CurrentTransactionContext, Is.Null); } if (node.IsController) { var actualCommitState = await tcs.Task.ConfigureAwait(false); Assert.That(actualCommitState, Is.EqualTo(node.GetExpectedCommitState())); } }
private static async Task ExecuteNode(TransactionContextTestNode node) { if (node.Parent == null) Assert.That(TransactionContext.CurrentTransactionContext, Is.Null); var tcs = new TaskCompletionSource<TransactionContextState>(); using (var tx = new TransactionContext(node.Affinity)) { Assert.That(TransactionContext.CurrentTransactionContext, Is.EqualTo(tx)); Assert.That(tx.IsController, Is.EqualTo(node.IsController)); if (node.IsController) { tx.StateChanged += (s, e) => { if (e.NewState == TransactionContextState.Exited) tcs.SetResult(e.OldState); }; } await node.ExecuteOperation().ConfigureAwait(false); if (node.Children != null) { foreach (var child in node.Children) await ExecuteNode(child).ConfigureAwait(false); } if (node.VoteAction == VoteAction.VoteCommit) tx.VoteCommit(); else if (node.VoteAction == VoteAction.VoteRollback) tx.VoteRollback(); } if (node.Parent == null) Assert.That(TransactionContext.CurrentTransactionContext, Is.Null); if (node.IsController) { var actualCommitState = await tcs.Task.ConfigureAwait(false); Assert.That(actualCommitState, Is.EqualTo(node.GetExpectedCommitState())); } }