public void Test1() { for (var chunkSize = 1; chunkSize <= 100; chunkSize++) { for (var itemSize = 1; itemSize <= 1000; itemSize++) { var expectedNrOfChunks = (int)Math.Ceiling((float)itemSize / (float)chunkSize); var seq = Enumerable.Range(0, itemSize); var chunkIndex = 1; IChunkedList<int> chunk = new ChunkedList<int>(seq, chunkSize); do { try { var expectedChunkSize = chunkSize; if (chunkIndex == expectedNrOfChunks) { expectedChunkSize = itemSize % chunkSize; if (expectedChunkSize == 0) { expectedChunkSize = chunkSize; } } var expectedItems = Enumerable.Range((chunkIndex - 1) * chunkSize, expectedChunkSize); Assert.IsTrue(chunk.CurrentChunk .SequenceEqual(expectedItems)); if (chunk.HasMoreChunks) { chunk = chunk.GetNextChunk(); } else { break; } } finally { ++chunkIndex; } } while (true); Assert.AreEqual(expectedNrOfChunks, chunkIndex - 1); } } }