I suggest you ...

SetupSequence() : More operators

Be able to use SetupSequence like this : Example : The first time, I want the method returns 0, then it returns 1.

mock.SetupSequence(x => x.GetNumber())
.ReturnsFirst(0)
.ThenReturns(1);

Today, to do this I write this, it's a little bit verbose...

var firstTime = true;

mock.Setup(x => x.GetNumber())
.Returns(()=>
{
if(!firstTime)
return 1;

firstTime = false;
return 0;
});

src : http://stackoverflow.com/questions/11308328/moq-setupsequence

I think it could be a good improvement to deal with sequences to add
some function like these.

31 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Florian NouriFlorian Nouri shared this idea  ·   ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • AnonymousAnonymous commented  · 

        Btw, the current implementation is not thread safe.

      Feedback and Knowledge Base