コード例 #1
0
        public void ShouldCommit()
        {
            // arrange
            TransactionAttribute.FactoryResolver = Resolver.Get;
            TransactionAttribute attr = new TransactionAttribute();
            Resolver.Reset();

            // act
            attr.OnResultExecuted(m_context);

            // assert
            Resolver.Factory.Verify(x => x.GetCurrentUnitOfWork());
            Resolver.UoW.Verify(x => x.Commit());
        }
コード例 #2
0
        public void ShouldNotCommitIfNullUoW()
        {
            // arrange
            Resolver.Get();
            TransactionAttribute.FactoryResolver = Resolver.Get;
            TransactionAttribute attr = new TransactionAttribute();
            //Resolver.Reset();
            Resolver.ReturnNullUoW = true;

            // act
            attr.OnResultExecuted(m_context);

            // assert
            Resolver.Factory.Verify(x => x.GetCurrentUnitOfWork());
        }
コード例 #3
0
        public void ShouldNotCommitIfModelStateInvalid()
        {
            // arrange
            Resolver.Get();
            TransactionAttribute.FactoryResolver = Resolver.Get;
            TransactionAttribute attr = new TransactionAttribute();
            m_context.Controller.ViewData.ModelState.AddModelError("Data", "Error");
            //Resolver.Reset();

            // act
            attr.OnResultExecuted(m_context);

            // assert
            Resolver.Factory.Verify(x => x.GetCurrentUnitOfWork(), Times.Never());
        }