public static void AssertValues <T>(this PageResponse <T> pageResponse, bool success, int totalItems, int pageSize, int page, int totalPages) where T : new() { const string messageFormat = "Page response:\n{0}\n\nExpected {1} to equal {2}"; var json = pageResponse.TestSerialise(); Func <string, dynamic, string> testMessage = (property, count) => string.Format(messageFormat, json, property, count); Assert.IsTrue(pageResponse.Success == success, testMessage("success", success)); Assert.IsTrue(pageResponse.TotalItems == totalItems, testMessage("totalitems", totalItems)); Assert.IsTrue(pageResponse.PageSize == pageSize, testMessage("pagesize", pageSize)); Assert.IsTrue(pageResponse.Page == page, testMessage("page", page)); Assert.IsTrue(pageResponse.TotalPages == totalPages, testMessage("totalpages", totalPages)); Assert.IsNotNull(pageResponse.Content, "page content is null"); Assert.IsTrue(pageResponse.Content.Count == totalItems, testMessage("content length", totalItems)); }