Пример #1
0
        public void GetFunctionDataTest()
        {
            #region arrange

            List <FunctionVO> reFunctionVO = new List <FunctionVO>()
            {
                new FunctionVO()
                {
                    FunctionID = 1, Url = "Role/RoleManagement", Title = "角色管理", Description = "瀏覽角色管理畫面", IsMenu = true, Parent = 0, ParentName = "No"
                },
                new FunctionVO()
                {
                    FunctionID = 2, Url = "Role/RoleAddEditDelete", Title = "編輯角色", Description = "角色新增修改刪除畫面", IsMenu = true, Parent = 1, ParentName = "角色管理"
                },
                new FunctionVO()
                {
                    FunctionID = 3, Url = "Role/EditRole", Title = "編輯", Description = "編輯角色", IsMenu = false, Parent = -1, ParentName = "Not Menu"
                }
            };

            List <FunctionDTO> reFunctionDTO = new List <FunctionDTO>()
            {
                new FunctionDTO()
                {
                    FunctionID = 1, Url = "Role/RoleManagement", Title = "角色管理", Description = "瀏覽角色管理畫面", IsMenu = true, Parent = 0, ParentName = "No"
                },
                new FunctionDTO()
                {
                    FunctionID = 2, Url = "Role/RoleAddEditDelete", Title = "編輯角色", Description = "角色新增修改刪除畫面", IsMenu = true, Parent = 1, ParentName = "角色管理"
                },
                new FunctionDTO()
                {
                    FunctionID = 3, Url = "Role/EditRole", Title = "編輯", Description = "編輯角色", IsMenu = false, Parent = -1, ParentName = "Not Menu"
                }
            };

            int renumber = 3;

            PageDataVO pageDataVO = new PageDataVO()
            {
                PageNumber     = 1,
                WhereCondition = new List <KeyValueVO>()
                {
                    new KeyValueVO()
                    {
                        Key   = "Url",
                        Value = ""
                    }
                }
            };

            _functionRepo.Stub(o => o.GetFunctionCount(pageDataVO)).Return(renumber);

            _functionRepo.Stub(o => o.GetFunctionData(pageDataVO)).Return(reFunctionDTO);

            #endregion

            #region act

            var result = _target.GetFunctionData(pageDataVO).ToList();

            #endregion

            #region assert

            for (int i = 0; i < result.Count(); i++)
            {
                Assert.AreEqual(result[i].FunctionID, reFunctionVO[i].FunctionID);
                Assert.AreEqual(result[i].Url, reFunctionVO[i].Url);
                Assert.AreEqual(result[i].Title, reFunctionVO[i].Title);
                Assert.AreEqual(result[i].Description, reFunctionVO[i].Description);
                Assert.AreEqual(result[i].IsMenu, reFunctionVO[i].IsMenu);
                Assert.AreEqual(result[i].Parent, reFunctionVO[i].Parent);
                Assert.AreEqual(result[i].ParentName, reFunctionVO[i].ParentName);
            }

            #endregion
        }