Multiple return values for When/Do

74 views
Skip to first unread message

Łukasz Łysik

unread,
Jan 22, 2014, 10:18:06 AM1/22/14
to nsubs...@googlegroups.com
I need to use when/do feature which is different over different calls.

In the documentation there is an example, and the description which says, that the "Do" corresponds to "Returns" method for non-void methods. So I'd expect that it would be possible to use it this way: 

var foo = Substitute.For<IFoo>();
    foo.When(x => x.SayHello("World"))
        .Do(x => { throw new Exception;}, x => {return counter++; });

However, "Do" function doesn't accept multiple parameters. Do you plan to implement this feature? How can I achieve this functionality in a neat way?

Thanks,
Lukasz 

David Tchepak

unread,
Jan 22, 2014, 4:31:18 PM1/22/14
to nsubs...@googlegroups.com
Hi Lukasz,

I hadn't thought of that before. The feature isn't planned, but you can use a Queue<Action<CallInfo>> to get the behaviour you want. 


Regards,
David



--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nsubstitute...@googlegroups.com.
To post to this group, send email to nsubs...@googlegroups.com.
Visit this group at http://groups.google.com/group/nsubstitute.
For more options, visit https://groups.google.com/groups/opt_out.

Łukasz Łysik

unread,
Jan 22, 2014, 4:35:02 PM1/22/14
to nsubs...@googlegroups.com
 Cool! Thanks a lot.


2014/1/22 David Tchepak <tch...@gmail.com>
Reply all
Reply to author
Forward
0 new messages