On Fri, May 6, 2011 at 5:20 AM, Giulio Petrucci <[email protected]> wrote: > Hi Patrick, > > thanks again for you reply. > > On Thu, May 5, 2011 at 5:48 PM, Patrick Steele <[email protected]> > wrote: >> Personally, I don't like testing the implementation details. > [cut] > > What do you mean with "testing implementation details" referring to > the approach I suggested? I ask in order to avoid similar errors in > future.
Your current implementation (from your previous emails) suggests your blacklist is a List<T>. When pulling data back from the repository, you were looking to set an expectation that List<T>.Contains() is called to ensure your blacklist is being checked. This means that if you change your implementation of your blacklist (perhaps to a Dictionary<K,T>), your unit test will break. Even though the BEHAVIOR may be the same, the unit test is not testing the behavior of the method, but the implementation (that it uses List<T>.Contains). Your unit tests will be less brittle if you focus on testing behavior. Now, if you really want to make sure that your blacklist is consulted before returning data, I would create a blacklist component (perhaps an IBlacklist interface) that contains just want you need to populate and query the blacklist. With an interface, you can set your expectations, and since it IS just an interface, the implementation of how the IBlacklist is implemented is, again, not important to your original method. --- Patrick Steele http://weblogs.asp.net/psteele -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
