예제 #1
0
            public void SingleThread_Sync_MultipleUowsCreation()
            {
                IPersistenceUnitOfWork uow1;

                using (uow1 = Subject.Create())
                {
                    uow1.Complete();
                }

                IPersistenceUnitOfWork uow2;

                using (uow2 = Subject.Create())
                {
                    uow2.Complete();
                }


                // assert
                IPersistenceContextExplicit context1 = uow1.Context as IPersistenceContextExplicit;
                IPersistenceContextExplicit context2 = uow2.Context as IPersistenceContextExplicit;

                Assert.AreNotSame(uow2, uow1);
                Assert.AreNotSame(context2, context1);

                context1.Received(1).Flush();
                context2.Received(1).Flush();
            }
예제 #2
0
            public void SingleThread_Sync_InnerUowsCreation()
            {
                IPersistenceUnitOfWork uow, innerUow, innerInnerUow;

                using (uow = Subject.Create())
                {
                    using (innerUow = Subject.Create())
                    {
                        using (innerInnerUow = Subject.Create())
                        {
                            innerInnerUow.Complete();
                        }
                        innerUow.Complete();
                    }
                    uow.Complete();
                }

                // assert
                IPersistenceContextExplicit context           = uow.Context as IPersistenceContextExplicit;
                IPersistenceContext         childContext      = innerUow.Context;
                IPersistenceContext         grandChildContext = innerInnerUow.Context;

                Assert.AreNotSame(uow, innerUow);
                Assert.AreNotSame(uow, innerInnerUow);
                Assert.AreNotSame(innerUow, innerInnerUow);

                Assert.AreSame(context, childContext);
                Assert.AreSame(context, grandChildContext);

                context.Received(1).Flush();
            }
예제 #3
0
            public void SingleThread_Sync_UowCreation()
            {
                IPersistenceUnitOfWork uow;

                using (uow = Subject.Create())
                {
                    uow.Complete();
                }

                // assert
                IPersistenceContextExplicit context = uow.Context as IPersistenceContextExplicit;

                context.Received(1).Flush();
            }
            public void SingleThread_Sync_UowWithTransactionCreation()
            {
                bool isActiveBeforeSave, isActiveAfterSave;
                IPersistenceUnitOfWork uow;

                using (uow = Subject.CreateWithTransaction(IsolationLevel.ReadCommitted))
                {

                    isActiveBeforeSave = uow.Context.IsInActiveTransaction;

                    uow.Complete();
                    isActiveAfterSave = uow.Context.IsInActiveTransaction;
                }

                // assert
                IPersistenceContextExplicit context = uow.Context as IPersistenceContextExplicit;
                context.Received(1).Flush();


                Assert.IsTrue(isActiveBeforeSave);
                Assert.IsFalse(isActiveAfterSave);
            }