mercredi 12 août 2020

C# .NET Core - Factory method vs Constructor

I have a class with a constructor that only sets the private attributes. This class is used in many automated tests and I need to add another private attribute. What is a good approach to avoid updating the instances of the class in the test methods? Should I overload the constructor or use factory pattern?

I thought when the new private attribute is not important in test cases such as adding an ILogger then I can overload the constructor but if the private attribute is required in test cases, then I better use the factory method. What is your suggestion?

Aucun commentaire:

Enregistrer un commentaire