• All Posts
  • Code
  • Design
  • Process
  • Speaking
  • Poetry
  • About
D.

November 01, 2012 Trying out NSubstitute

I might be professionally finished with Rhino Mocks and Moq.

I’ve been poking at NSubstitute for a side project and the syntax reads beautifully.

Create a fake IWidget

[code language=”csharp”] IWidget fakeWidget = Substitute.For<IWidget>(); [/code]

Set expectations on a method

[code language=”csharp”] fakeWidget.DoSomething().Returns(fakedReturnValue); [/code]

Set expectations on a property

[code language=”csharp”] fakeWidget.SomeProperty.Returns(fakedPropertyValue); [/code]


back to top

© David Alpert 2025