To save a sequence, InSequence()
method call is not required. To make sure you can see the source code:
private class ReturnsManyImpl<TReturn>
{
internal int CurrentIndex;
private readonly IList<TReturn> values;
private readonly Action<ReturnsManyImpl<TReturn>> afterEndAction;
public ReturnsManyImpl(IList<TReturn> values, Action<ReturnsManyImpl<TReturn>> afterEndAction)
{
this.afterEndAction = afterEndAction;
this.values = values;
}
internal TReturn GetNext()
{
if (CurrentIndex >= values.Count)
afterEndAction(this);
return values[CurrentIndex++];
}
}
But remember about behavior
parameter, by default it is equal to AfterLastValue.KeepReturningLastValue
.