public void GivenAListOfPersistedEntities_WhenQuerying_APagedListOfEntitiesIsReturned() { var fakeResults = Enumerable.Range(0, 100) .Select(id => new Entity { Id = id }); authorizationServiceMock.Setup(r => r.HasRole(It.IsAny <int>(), EntityRole.Owner)).Returns(false); contextMock.SetupGet(r => r.Entities).Returns(fakeResults.ToDbSet()); var fakeReturn = new PagedList <Entity>(); queryHelperMock.Setup(r => r.Query(It.IsAny <IQueryable <Entity> >(), 10, 0, It.IsAny <Expression <Func <Entity, bool> > >())).Returns(fakeReturn); var result = entitiesController.QueryEntities() as JsonResult; var entities = result.Value as PagedList <Entity>; //queryHelperMock.Verify(r => r.Query(fakeResults.ToDbSet(), 10, 0, It.IsAny<Expression<Func<Entity, bool>>>())).Returns(fakeReturn); Assert.IsInstanceOfType(entities, typeof(PagedList <Entity>)); Assert.AreEqual(fakeReturn, entities); }