I think changing the default behavior for mocks to return values other than the defaults would be a risky step.
What happens if an error occurs in your real ICustomerRepository implementations so that it does not return an empty list and instead returns null?
If you wrote other unit tests and tested against mock versions of ICustomerRepository that automatically returned an empty list, then you would think that everything is in order. You can even create this code and think that it will work correctly, so you start your compiled application and it starts to crash.
Why? Since your classes that got into ICustomerRepository did not properly process zeros.
I would rather be explicit and set the wait in the test to return an empty IList from the getCustomers () method than something “magic” in the layout. What for? Since it improves readability, and the code works in a way that other developers who might not be so familiar with the rhino expected it to work. that is, a method without waiting returns a default value.
Richard Banks
source share