Return Null in NSubstitute Mock Framework

The API is not intuitive, at least not for me. So, I have to figure out how to return null with this mocking framework I have never used before.

var service = Substitute.For<ISomethingService>();

// Mock
service.Get<IEnumerable<SomeDomain>>(Arg.Any<string>()).ReturnsForAnyArgs(x => null);

Normally, I would just to .ReturnsForAnyArgs(null), not the case with NSubstitute.

Advertisements

1 thought on “Return Null in NSubstitute Mock Framework”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s