I've created a few small fluent interfaces through method chaining. They typically call a number of Repositories that fetch data from webservices / databases.

How should I go about unit testing methods that use the fluent interface?

Public IEnumberable<Computer> FindComputers(string serialNumber)
{
      return Computers.FindBySerialNumber("YBCX00900")
         .AttachConfiguration()
         .EnsureAllComputersHaveConfiguration();
}

I can unit test the individual components of the fluent interface, but if I want to unit test the FindComputers method above what should I do?

  1. Use the concrete implementation of the fluent interface, and write expectations on the Repository classes
  2. Mock the fluent interface itself and set expectations on that
  3. Test only the fluent interface itself, and not the FindComputers() method

I'd like to find an easily maintainable approach.

Edit
Report