public void Should_batch() { // Arrange var actualCollection = new List <Item>(); var expectedCollection = Enumerable.Range(0, 100).Select(x => new Item { Id = x }).ToList(); var query = expectedCollection.AsQueryable().OrderBy(x => x.Id); // Act foreach (var items in _batchService.Batch(query, 10)) { actualCollection.AddRange(items); } // Assert actualCollection.Should().BeEquivalentTo(expectedCollection); }