0

I am arranging call for a method in a unit test like below

container.Arrange(p=> p.doSomething(Arg.AnyString, Arg.AnyString)).ReturnsMany(1, 2);

Is 1 and 2 will be returned in sequence always or InSequence() chain is required?

Will ReturnsMany returns values in sequence or explicit InSequence is required?

Docs: https://docs.telerik.com/devtools/justmock/api/overload_telerik_justmock_helpers_multiplereturnvaluechainhelper_returnsmany

user1853803
  • 649
  • 3
  • 8
  • 27
  • What is your question about? – Pavel Anikhouski Jun 06 '20 at 17:30
  • Knowing nothing about this, I can tell you that the docs you linked to say that it configures multiple calls to a method, so it seems you don't have to call anything else and it will set up the values to return in sequence – pinkfloydx33 Jun 06 '20 at 19:43

1 Answers1

0

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.

smolchanovsky
  • 1,775
  • 2
  • 15
  • 29