A fake implementation for a DataSet , for example, will simply return a static dataset. The layout would be pretty much a complete implementation that could generate different data sets depending on the input. If you mocked your data level, you could execute your command objects against the layout, and it would be strong enough to return data using a βvalidβ statement or throw exceptions with an invalid statement. All without actually connecting to a database or file.
As for the differences between mock and real, usually when you mock a class, you should create a factory object that returns the real object by default, but when you write your tests, you can tell it to return a specific class layout. The mock class implements the same interfaces as the real object, or you use a wrapper class that mimics the base class but allows dependency injection for critical parts to generate data without external calls.
source share