7
Vote

Auto-mocking extensions should auto-fill properties

description

See the discussion in the comments here http://blog.ploeh.dk/2010/08/19/AutoFixtureAsAnAutomockingContainer.aspx

No files are attached

comments

baxevanis wrote Sep 9 2011 at 7:53 AM

...Indeed :)

ploeh wrote Sep 9 2011 at 7:35 AM

While I agree that this would make it easier to work with HttpContextBase and its ilk, keep in mind that this basically demonstrates how crappy an API the web abstractions actually are ;)

dhilgarth wrote Sep 9 2011 at 6:23 AM

Please have a look at the AutoNSubstitute fork. In this I implemented the auto-filling functionality for mocks created with NSubstitute. Does it behave the way you expected?

baxevanis wrote Sep 8 2011 at 8:26 PM

That would be nice. For example, in order to mock an IController interface and fill the User property one needs to create mocks for IPrincipal, HttpContextBase and ControllerContext then assign the User to HttpContextBase, assign that to ControllerContext and finally assign to mocked controller instance.

This overall process will by done automatically, I think, when this feature is implemented. So this would be a very nice extension.

dhilgarth wrote Sep 8 2011 at 3:00 PM

As I commented on the blog, it might be a good idea to let the user choose whether he want to have the properties of his mocks filled or not. Why? Because at least for Rhino Mocks and Moq it makes a difference, as they support auto property behavior or null behavior (values assigned to properties are lost, properties always return default(T))