How do you unit test a class that's meant to talk to data?

Posted by Arda Xi on Stack Overflow See other posts from Stack Overflow or by Arda Xi
Published on 2010-05-02T11:02:45Z Indexed on 2010/05/02 11:07 UTC
Read the original article Hit count: 276

I have a few repository classes that are meant to talk to different kinds of data, deriving from an IRepository interface laid out like so:

IRepository interface

In implementations, the code talks to a data source, be this a directory of XML files or a database or even just a cache. Is it possible to reliably unit test any of these implementations? I don't see a mock implementation working, because then I'm only testing the mock code and not the actual code.

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about TDD