Archives

Archives / 2011 / March
  • Mocking constructor

    While unit testing a target type, it is likely that the test is failing during object creation because we forgot to include a mandatory configuration file or a line in the constructor is throwing exception because it is making call to some external service or data store which on the other hand requires a little more orchestration to get things going . To better illustrate this, let’s create an entity framework data container either new or from an existing database. Once we have completed the required steps, there will be an entry-point class where we will notice the following default constructor: