Skip to content

Commit

Permalink
Test immutability of Windowed windows
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed May 30, 2018
1 parent 2f5eafe commit 99aa8c3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions MoreLinq.Test/WindowedTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,23 @@ public void TestWindowedSmallerThanSequence()
foreach (var window in result)
Assert.That(window, Is.EqualTo(sequence.Skip(++index).Take(windowSize)));
}

/// <summary>
/// Verify that later windows do not modify any of the previous ones.
/// </summary>

[Test]
public void TestWindowedWindowsImmutability()
{
using (var windows = Enumerable.Range(1, 5).Windowed(2).AsTestingSequence())
using (var reader = windows.ToArray().Read())
{
reader.Read().AssertSequenceEqual(1, 2);
reader.Read().AssertSequenceEqual(2, 3);
reader.Read().AssertSequenceEqual(3, 4);
reader.Read().AssertSequenceEqual(4, 5);
reader.ReadEnd();
}
}
}
}

0 comments on commit 99aa8c3

Please sign in to comment.