NullObject.For<T> - As simple as it gets, but no simpler - ISerializable - Roy Osherove's Blog

NullObject.For<T> - As simple as it gets, but no simpler

This NullObject Factory from Paul is very nice, simple and clean in its design. I really like it and I can see many uses for it, in parallel with working with your standard mocking framework or IoC Container Implementation.

 

here is a little usage example (last line):

var controller = new AccountController(         // Class I am testing
    mockCustomerRepository,                     // Class I am mocking
    NullObject.For<ILogger>());                 // Who cares about logging!
Published Saturday, May 10, 2008 5:19 PM by RoyOsherove

Comments

Sunday, May 11, 2008 2:08 AM by Scott Bellware

# re: NullObject.For<T> - As simple as it gets, but no simpler

Null Objects as constructor arguments are a design smell.  Detailed comment left on the original post:

www.paulstovell.com/.../nullobjectfor

Sunday, May 11, 2008 6:56 AM by Ian Horowitz

# re: NullObject.For<T> - As simple as it gets, but no simpler

What's the difference with the Dynamic Mock from Rhino Mocks ?