Q:

Unit Testing - How to Compare Two Paged Collections To Assert All Items Different?

Had a quick look here, couldn't find a duplicate (correct me if im wrong).
I've got the following Unit Test for some Paging with LINQ:
    // Arrange.
    const int locationId = 1;
    const LocationType locationType = LocationType.City;
    int pageSize = 10;

    // Act.
    var postsPageOne = PostService.FindAllPostsForLocationPaged<Review>(locationId, locationType, 1, pageSize);
    var postsPageTwo = PostService.FindAllPostsForLocationPaged<Review>(locationId, locationType, 2, pageSize);

    // Assert.
    Assert.IsTrue(postsPageOne.Count > 0);
    Assert.IsTrue(postsPageTwo.Count > 0);
    Assert.AreEqual(postsPageOne.Count, pageSize);
    Assert.AreEqual(postsPageTwo.Count, pageSize);
    CollectionAssert.AllItemsAreNotNull(postsPageOne.ToArray());
    CollectionAssert.AllItemsAreNotNull(postsPageTwo.ToArray());

I want to assert that all items in the collection postsPageOne are different to all the items in the collection postsPageTwo. (seems like the way to test paging)
Any ideas of how I can do that?

A:

That doesn't sound like the way to test paging to me. I would test paging by having a known dataset, and checking that each page does contain the data I'd expect it to. Otherwise your code could just make up random data, and so long as it was different, your test would pass.
Use a small page size (e.g. 2 or 3) to keep the amount of data to test nice and small.

A:

Assert.IsFalse(postsPageOne.Intersect(postsPageTwo).Any());

