There is a better approach to do that.
Look, that you have made your isTest
variable public - this is dangerous. The better solution for that problem, would be to create new configuration in your solution and call it TEST. Next in your test app just add TEST to defines. And in your code:
public Model PrepareModel(){
Model model = new Model();
model.mainPropertie = getFromDataBase();
#if !TEST
model.someIrrelevantProperty1 = getValueFromSomeDependency();
model.someIrrelevantProperty2 = getValueFromSomeDependency();
#endif
model.newFeature = myNewCode();
return model;
}
Of course, this assumes that test would only be running in TEST configuration*
If you don't know what I mean by "configuration" it's just another one beside DEBUG and RELEASE.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…