public void QueryFunctionTest() { #region arrange List <FunctionVO> reFunctionList = 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" } }; PageDataVO pageDataVO = new PageDataVO() { PageNumber = 1, PageSize = 5, WhereCondition = new List <KeyValueVO>() { new KeyValueVO() { Key = "Url", Value = "" } } }; _functionService.Stub(o => o.GetFunctionData(pageDataVO)).Return(reFunctionList); #endregion #region act var resultData = _target.QueryFunction(pageDataVO); var result = (FunctionTableResultVO)((JsonResult)resultData).Data; var roleData = result.FunctionData.ToList(); #endregion #region assert for (int i = 0; i < roleData.Count; i++) { Assert.AreEqual(roleData[i].FunctionID, reFunctionList[i].FunctionID); Assert.AreEqual(roleData[i].Url, reFunctionList[i].Url); Assert.AreEqual(roleData[i].Title, reFunctionList[i].Title); Assert.AreEqual(roleData[i].Description, reFunctionList[i].Description); Assert.AreEqual(roleData[i].IsMenu, reFunctionList[i].IsMenu); Assert.AreEqual(roleData[i].Parent, reFunctionList[i].Parent); Assert.AreEqual(roleData[i].ParentName, reFunctionList[i].ParentName); } #endregion }