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.
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.
public LoadDataProcess(KonstruktEntities context, IDataLoadedChecker dataLoadedChecker, ILoadUserBudgetData dataLoader, ISetLineAccess setBudgetLineStatus, ILineAccessFilterHandler budgetDataLineStatusFilterHandler)
{
_context = context;
_dataLoadedchecker = dataLoadedChecker;
_dataLoader = dataLoader;
_setBudgetLineStatus = setBudgetLineStatus;
_budgetDataLineStatusFilterHandler = budgetDataLineStatusFilterHandler;
}
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.
Question is, should we be injecting DAL dependencies into BL classes at all?