Skip to content

Commit

Permalink
Add TestInterleaveDoNotCallGetEnumeratorEagerly
Browse files Browse the repository at this point in the history
  • Loading branch information
Orace committed Dec 12, 2019
1 parent 673b42c commit 0316143
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions MoreLinq.Test/InterleaveTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ public void TestInterleaveIsLazy()
new BreakingSequence<int>().Interleave(new BreakingSequence<int>());
}

/// <summary>
/// Verify that interleaving do not call enumerators MoveNext method eagerly
/// </summary>
[Test]
public void TestInterleaveDoNoCallMoveNextEagerly()
{
var sequenceA = Enumerable.Range(1, 1);
var sequenceB = MoreEnumerable.From<int>(() => throw new TestException());

sequenceA.Interleave(sequenceB).Take(1).Consume();
}

/// <summary>
/// Verify that interleaving disposes those enumerators that it managed
/// to open successfully
Expand Down Expand Up @@ -75,6 +63,30 @@ public void TestInterleaveDisposesOnErrorAtMoveNext()
Assert.Throws<TestException>(() => sequenceA.Interleave(sequenceB).Consume());
}

/// <summary>
/// Verify that interleaving do not call enumerable GetEnumerator method eagerly
/// </summary>
[Test]
public void TestInterleaveDoNotCallGetEnumeratorEagerly()
{
var sequenceA = TestingSequence.Of(1);
var sequenceB = new BreakingSequence<int>();

sequenceA.Interleave(sequenceB).Take(1).Consume();
}

/// <summary>
/// Verify that interleaving do not call enumerators MoveNext method eagerly
/// </summary>
[Test]
public void TestInterleaveDoNoCallMoveNextEagerly()
{
var sequenceA = Enumerable.Range(1, 1);
var sequenceB = MoreEnumerable.From<int>(() => throw new TestException());

sequenceA.Interleave(sequenceB).Take(1).Consume();
}

/// <summary>
/// Verify that two balanced sequences will interleave all of their elements
/// </summary>
Expand Down

0 comments on commit 0316143

Please sign in to comment.