From aece77c23e2b2203ca857553bb9ab03a04d33784 Mon Sep 17 00:00:00 2001 From: Orace Date: Thu, 12 Dec 2019 10:44:40 +0100 Subject: [PATCH 1/2] Add TestSortedMergeDoNotCallMoveNextEagerly --- MoreLinq.Test/SortedMergeTest.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MoreLinq.Test/SortedMergeTest.cs b/MoreLinq.Test/SortedMergeTest.cs index bc21204be..66f638e19 100644 --- a/MoreLinq.Test/SortedMergeTest.cs +++ b/MoreLinq.Test/SortedMergeTest.cs @@ -54,6 +54,17 @@ public void TestSortedMergeDisposesOnError() } } + /// + /// Verify that SortedMerge do not call MoveNext method eagerly + /// + [Test] + public void TestSortedMergeDoNotCallMoveNextEagerly() + { + var sequenceA = TestingSequence.Of(1, 3); + var sequenceB = MoreEnumerable.From(() => 2, () => throw new TestException()); + sequenceA.SortedMerge(OrderByDirection.Ascending, sequenceB).Take(2).Consume(); + } + /// /// Verify that SortedMerge throws an exception if invoked on a null sequence. /// From 720c020a2f45bd21c8d6eb64df5f5da078e7e70b Mon Sep 17 00:00:00 2001 From: Orace Date: Tue, 27 Jun 2023 08:00:43 +0200 Subject: [PATCH 2/2] Update MoreLinq.Test/SortedMergeTest.cs Co-authored-by: Atif Aziz --- MoreLinq.Test/SortedMergeTest.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MoreLinq.Test/SortedMergeTest.cs b/MoreLinq.Test/SortedMergeTest.cs index 66f638e19..8a26838ab 100644 --- a/MoreLinq.Test/SortedMergeTest.cs +++ b/MoreLinq.Test/SortedMergeTest.cs @@ -60,9 +60,13 @@ public void TestSortedMergeDisposesOnError() [Test] public void TestSortedMergeDoNotCallMoveNextEagerly() { - var sequenceA = TestingSequence.Of(1, 3); - var sequenceB = MoreEnumerable.From(() => 2, () => throw new TestException()); - sequenceA.SortedMerge(OrderByDirection.Ascending, sequenceB).Take(2).Consume(); + 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); } ///