design business class for unit test
- by Mauro Destro
I'm trying to clean my code to make it unit-testable. I know that unit tests must be created while coding but... I have to do it now, with code completed.
My business class is full of methods with a similar implementation like:
var rep=new NHrepository<ModelClass1>(Session);
rep.Where(x=>x.Field1==1).ToList();
first error (from my point of view) is that I don't have to use "new" but instead use DI and add in the ctor parameters a INHrepository modelClass1Repository.
If in my class I have two or more repository of different model class? Each must be in the ctor? Or probably business class is not build with SeparationOfConcern principle?