Provides data for the TransactionContext.Created event.
Inheritance: System.EventArgs
Beispiel #1
0
        private static void OnTransactionContextCreated(object sender, TransactionContextCreatedEventArgs e)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            if (e.NewTransactionContext.Affinity != TransactionContextAffinity.NotSupported)
            {
                e.NewTransactionContext.StateChanged += OnTransactionContextStateChanged;
            }
        }
		private static void NoContextTest_TransactionContextCreated(object sender, TransactionContextCreatedEventArgs e)
		{
			Assert.IsNull(TransactionContext.CurrentTransactionContext);

			var context = e.NewTransactionContext;
			Assert.IsNotNull(context);

			Assert.IsNull(context.Parent);
			Assert.AreEqual(TransactionContextAffinity.NotSupported, context.Affinity);
			Assert.AreEqual(IsolationLevel.ReadCommitted, context.IsolationLevel);
			Assert.AreEqual(TransactionContextState.Created, context.State);

			context.StateChanged +=
				(s2, e2) =>
				{
					if (e2.NewState == TransactionContextState.Entered)
						Assert.AreEqual(TransactionContext.CurrentTransactionContext, s2);
					else if (e2.NewState == TransactionContextState.Exited)
						Assert.AreEqual(TransactionContextState.ToBeCommitted, e2.OldState);
				};
		}