OnActionExecuted() public method

public OnActionExecuted ( System.Web.Mvc.ActionExecutedContext filterContext ) : void
filterContext System.Web.Mvc.ActionExecutedContext
return void
示例#1
0
        public void Test_Should_not_commit_if_there_is_Exception()
        {
            var uowAttr = new UnitOfWorkAttribute();
            var mockUoW = new Mock<IUnitOfWork>();
            mockUoW.Setup(u => u.Commit()).Throws<InvalidOperationException>();

            uowAttr.UnitOfWork = mockUoW.Object;
            uowAttr.OnActionExecuted(new ActionExecutedContext() { Exception = new Exception() });
        }
示例#2
0
        public void Test_Should_Commit_if_there_is_no_exception()
        {
            var uowAttr = new UnitOfWorkAttribute();
            var mockUoW = new Mock<IUnitOfWork>();
            mockUoW.Setup(u => u.Commit()).Verifiable();

            uowAttr.UnitOfWork = mockUoW.Object;
            uowAttr.OnActionExecuted(new ActionExecutedContext());

            mockUoW.Verify();
        }