I am new to mockery and addiction and need some guidance.
My application uses a typical N-tier architecture, where the BLL refers to the DAL, and the user interface refers to the BLL, but not the DAL. Pretty straight forward.
Say, for example, I have the following classes:
class MyDataAccess : IMyDataAccess {}
class MyBusinessLogic {}
Each of them exists in a separate assembly.
I want to mock MyDataAccess in tests for MyBusinessLogic. So I added a constructor for the MyBusinessLogic class to accept the IMyDataAccess parameter for dependency injection. But now, when I try to create an instance of MyBusinessLogic at the user interface level, it requires a DAL reference.
I thought I could define a default constructor in MyBusinessLogic to set the standard implementation of IMyDataAccess, but not only does this look like a code tree, it actually did not solve the problem. I will still have a public constructor with IMyDataAccess in the signature. Thus, the UI layer still requires a DAL reference to compile.
One of the possible solutions that I encounter is to create an internal constructor for MyBusinessLogic with the IMyDataAccess parameter. Then I can use Accessor from the test project to call the constructor. But there is still this smell.
What is the general solution here. I just have to do something wrong. How can I improve the architecture?