@Paul:
I'm also new to mocking, but looking at your implementation I can't stop wonder that what you are doing is adapt the code to allow mocking, breaking code logic. My point is, and taking Owen's class as example, if we have another public (or internal) method in our class, why should we move that logic to an interface? This is forcing the class consumer to create additional code.
For example: let assume we have a class that has two methods: One for returning a list of countries and another that, based on a suplied countrycode, searches the countries list for the correct description:
public virtual string GetCountry(string code)
{
IOrderedEnumerable<KeyValuePair<string, string>> countries = GetCountries();
var result = countries.Where(x => x.Key.Equals(code)).Single();
return result.Value;
}
if I understood correctly, I would have to change this method signature to receive an additional parameter so I could correctly mock this class method's:
public virtual string GetCountry(ICountriesList list, string code)
{
IOrderedEnumerable<KeyValuePair<string, string>> countries = list.GetCountries();
var result = countries.Where(x => x.Key.Equals(code)).Single();
return result.Value;
}
Or is it another way?
Thanks.