public void GetActiveDataPageableTest() { PagedResult <Test> expectedResult; _repository .Setup(it => it.GetActiveDataPageable(It.IsAny <String>(), It.IsAny <Int32>(), It.IsAny <Int32>())) .Returns <String, Int32, Int32>((sortExpression, page, pageSize) => { var query = _repositoryList; switch (sortExpression) { case "Id": query = new List <Test>(query.OrderBy(q => q.Id)); break; case "TestTypeId": query = new List <Test>(query.OrderBy(q => q.TestTypeId)); break; case "ProjectId": query = new List <Test>(query.OrderBy(q => q.ProjectId)); break; case "GroupId": query = new List <Test>(query.OrderBy(q => q.GroupId)); break; case "Name": query = new List <Test>(query.OrderBy(q => q.Name)); break; case "TestValue": query = new List <Test>(query.OrderBy(q => q.TestValue)); break; case "IsActive": query = new List <Test>(query.OrderBy(q => q.IsActive)); break; } return(query.Take(pageSize).Skip((page - 1) * pageSize).ToList()); }); _repository .Setup(it => it.GetActiveDataRowCount()) .Returns(_repositoryList.Count); var result = _target.GetActiveDataPageable("Id", 1, PageSizeValue); Assert.IsTrue(result.TryGetContentValue(out expectedResult)); Assert.AreEqual(_repositoryList.Take(2).ToList().Count, expectedResult.Results.Count); Assert.AreEqual(_repositoryList.OrderBy(q => q.Id).FirstOrDefault().Id, expectedResult.Results.FirstOrDefault().Id); }