diff --git a/MoreLinq.Test/SortedMergeTest.cs b/MoreLinq.Test/SortedMergeTest.cs index a9ddb706b..7434df0c4 100644 --- a/MoreLinq.Test/SortedMergeTest.cs +++ b/MoreLinq.Test/SortedMergeTest.cs @@ -54,6 +54,21 @@ public void TestSortedMergeDisposesOnError() Throws.BreakException); } + /// + /// Verify that SortedMerge do not call MoveNext method eagerly + /// + [Test] + public void TestSortedMergeDoNotCallMoveNextEagerly() + { + using var sequenceA = TestingSequence.Of(1, 3); + using var sequenceB = MoreEnumerable.From(() => 2, () => throw new TestException()) + .AsTestingSequence(); + + var result = sequenceA.SortedMerge(OrderByDirection.Ascending, sequenceB).Take(2); + + Assert.That(() => result.Consume(), Throws.Nothing); + } + /// /// Verify that SortedMerge throws an exception if invoked on a null sequence. ///