Esempio n. 1
0
        protected void VerifyCanCreateUseAndDisposeNestedUnitOfWork()
        {
            Assert.AreEqual(-1, CurrentContext.UnitOfWorkNestingLevel, "level before starting UoW = -1");

            CurrentContext.CreateUnitOfWork();
            Assert.AreEqual(0, CurrentContext.UnitOfWorkNestingLevel, "level after starting UoW = 0");

            CurrentContext.CreateNestedUnitOfWork();
            Assert.AreEqual(1, CurrentContext.UnitOfWorkNestingLevel, "level after starting nested UoW = 1");

            UnitOfWork.CurrentSession.Save(new AREntity());
            UnitOfWork.CurrentSession.Flush();
            CurrentContext.DisposeUnitOfWork();

            //this is happening in the original UoW
            UnitOfWork.CurrentSession.Save(new AREntity());
            UnitOfWork.CurrentSession.Flush();
            CurrentContext.DisposeUnitOfWork();
        }
        protected void VerifyCanCreateUseAndDisposeNestedUnitOfWork()
        {
            Assert.AreEqual(-1, CurrentContext.UnitOfWorkNestingLevel, "level before starting UnitOfWork = -1");

            CurrentContext.CreateUnitOfWork();
            Assert.AreEqual(0, CurrentContext.UnitOfWorkNestingLevel, "level before starting UnitOfWork = 0");

            CurrentContext.CreateNestedUnitOfWork();
            Assert.AreEqual(1, CurrentContext.UnitOfWorkNestingLevel, "level after staring Nested UnitOfWork = 1");

            // in nested unit-of-work
            UnitOfWork.CurrentSession.Save(new GuidEntityForTesting());
            UnitOfWork.CurrentSession.Flush();
            CurrentContext.DisposeUnitOfWork();

            // in original unit-of-work
            UnitOfWork.CurrentSession.Save(new GuidEntityForTesting());
            UnitOfWork.CurrentSession.Flush();
            CurrentContext.DisposeUnitOfWork();
        }