Re: Returning null from a substitute

703 views
Skip to first unread message

Nick Parker

unread,
Dec 13, 2011, 5:20:48 PM12/13/11
to NSubstitute
The solution was to do something as follows:

repository.Find(id).Returns(x => null);

Nick Parker
www.developernotes.com


On Tue, Dec 13, 2011 at 4:12 PM, Nick Parker <ni...@developernotes.com> wrote:
Hello,

I've got a scenario where null may be returned from a method.  I would
like to test both scenarios of when that method returns null or not.
Is there a way to express that, I tried the following where repository
is my substitute and it doesn't work.  I am using NSubstitute 1.3.
Any thoughts?  Thanks!

repository.Find(id).Returns(null);

Nick Parker

unread,
Dec 13, 2011, 5:12:43 PM12/13/11
to NSubstitute
Reply all
Reply to author
Forward
0 new messages