public void TestMultiTransactions()
        {
            this.UnBindSession();

            using (ISessionBinderProvider provider = new SessionBinderProvider(this.SessionFactory.GetCurrentSession,
                                                                        this.LocalBindSession, this.LocalUnBindSession,
                                                                        () =>
                                                                        CurrentSessionContext.HasBind(
                                                                            this.SessionFactory)))
            {
                provider.BindSession();

                provider.BeginTransaction("first");
                Assert.IsTrue(provider.InProgress);

                provider.BeginTransaction("second");
                Assert.IsTrue(provider.InProgress);

                provider.BeginTransaction("third");
                Assert.IsTrue(provider.InProgress);

                provider.CommitTransaction();
                Assert.IsTrue(provider.InProgress);

                provider.CommitTransaction();
                Assert.IsTrue(provider.InProgress);

                provider.CommitTransaction();
                Assert.IsFalse(provider.InProgress);

                provider.UnBindSession();
            }
        }
        public void FailedSessionBinderProviderTest()
        {
            this.UnBindSession();

            ISessionBinderProvider provider = new SessionBinderProvider(this.SessionFactory.GetCurrentSession,
                                                                        this.LocalBindSession, this.LocalUnBindSession,
                                                                        () =>
                                                                        CurrentSessionContext.HasBind(
                                                                            this.SessionFactory));
            INhPagedDAO dao = new EnterprisePagedDAO(provider);
            dao.Load<Salesman>(1L);
        }
        public void TestMultiTransactionsWithRollback()
        {
            this.UnBindSession();

            using (ISessionBinderProvider provider = new SessionBinderProvider(this.SessionFactory.GetCurrentSession,
                                                                        this.LocalBindSession, this.LocalUnBindSession,
                                                                        () =>
                                                                        CurrentSessionContext.HasBind(
                                                                            this.SessionFactory)))
            {
                try
                {
                    provider.BindSession();

                    provider.BeginTransaction("first");
                    Assert.IsTrue(provider.InProgress);

                    provider.BeginTransaction("second");
                    Assert.IsTrue(provider.InProgress);

                    provider.BeginTransaction("third");
                    Assert.IsTrue(provider.InProgress);

                    provider.CommitTransaction(); /* commit the third transaction. */
                    Assert.IsTrue(provider.InProgress);

                    provider.RollbackTransaction();
                        /* this throws an exception because there are another inner transaction in progress. */
                }
                finally
                {
                    provider.UnBindSession();
                }
            }
        }
        public void TestTransactionsWithoutBindSession()
        {
            this.UnBindSession();

            using (ISessionBinderProvider provider = new SessionBinderProvider(this.SessionFactory.GetCurrentSession,
                                                                        this.LocalBindSession, this.LocalUnBindSession,
                                                                        () =>
                                                                        CurrentSessionContext.HasBind(
                                                                            this.SessionFactory)))
            {
                provider.BeginTransaction("first");
            }
        }