title: Inversion of Control and injection of data layer dependencies in the Business Layer
body: <p>We're designing a layered business application in .net/c# and we are trying to follow the SOLID-principles as much as we see fit. Testability is very important in our project and for this purpose we are using Moq. Using moq we are, among other things, mocking our entity framework context. </p>
  
  <p>As the main goal for our testing is the main business layer (BL) logic, the business layer classes can be injected with the Data Access Layer (DAL) context to use. See example below.
  sample constructor of a BL class responsible for loading data. This class injects dependencies for setting access, etc.</p>
  
  <pre><code>    public LoadDataProcess(KonstruktEntities context, IDataLoadedChecker dataLoadedChecker, ILoadUserBudgetData dataLoader, ISetLineAccess setBudgetLineStatus, ILineAccessFilterHandler budgetDataLineStatusFilterHandler) 
      {
          _context = context;
          _dataLoadedchecker = dataLoadedChecker;
          _dataLoader = dataLoader;
          _setBudgetLineStatus = setBudgetLineStatus;
          _budgetDataLineStatusFilterHandler = budgetDataLineStatusFilterHandler;
      }
  </code></pre>
  
  <p>Now, there are also other DAL dependencies that can be injected into our BL classes. Since these objects are beeing instanciated in the Service Layer (WCF) I don't like that DAL components can be injected.</p>
  
  <p>Question is, should we be injecting DAL dependencies into BL classes at all? </p>