Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to ensure Batch does not reuse internal array #820

Merged
merged 3 commits into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions MoreLinq.Test/BatchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ public void BatchSequenceYieldsListsOfBatches()
reader.ReadEnd();
}

[Test]
public void BatchSequencesAreIndependentInstances()
{
var result = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }.Batch(4);

using var reader = result.Read();
var first = reader.Read();
var second = reader.Read();
var third = reader.Read();
reader.ReadEnd();

first.AssertSequenceEqual(1, 2, 3, 4);
second.AssertSequenceEqual(5, 6, 7, 8);
third.AssertSequenceEqual(9);
}

[Test]
public void BatchIsLazy()
{
Expand Down