Exemple #1
0
        public void SaveRoleFunctionSettingTest()
        {
            #region arrange (處理有關選時的行為 成功)

            // httpContext物件設定
            var httpContext = FakeHttpContextManager.CreateHttpContextBase();
            httpContext.Response.StatusCode = 200;

            // 設定httpContext
            _target.CurrentHttpContext = httpContext;

            List <FunctionCheckVO> functionCheckVO = new List <FunctionCheckVO>()
            {
                new FunctionCheckVO()
                {
                    RoleID = 1, FunctionID = 1, Url = "Role/RoleManagement", Description = "瀏覽角色管理畫面", Check = true
                },
                new FunctionCheckVO()
                {
                    RoleID = 1, FunctionID = 2, Url = "Role/RoleAddEditDelete", Description = "角色新增修改刪除畫面", Check = true
                },
                new FunctionCheckVO()
                {
                    RoleID = 1, FunctionID = 3, Url = "Role/EditRole", Description = "編輯角色", Check = false
                }
            };

            string roleID = null;

            string reMessage = string.Empty;

            _functionService.Stub(o => o.SaveRoleFunctionSetting(Arg <List <FunctionCheckVO> > .Is.Anything)).Return(reMessage);

            SessionReflashSetting();

            #endregion

            #region act

            var resultData = _target.SaveRoleFunctionSetting(functionCheckVO, roleID);

            var result = (string)((JsonResult)resultData).Data;

            #endregion

            #region assert

            Assert.AreEqual(_target.CurrentHttpContext.Response.StatusCode, 200);

            Assert.AreEqual(result, reMessage);

            #endregion
        }