design business class for unit test

Posted by Mauro Destro on Stack Overflow See other posts from Stack Overflow or by Mauro Destro
Published on 2010-02-25T10:26:23Z Indexed on 2010/03/21 4:21 UTC
Read the original article Hit count: 413

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about design