The fact that I ask this question and do not see it anywhere makes me believe that my design / thinking is wrong, so it is very good, and my implementation can be greatly improved.
I have a singleton class ( like here ) in which I create material for a bunch of test classes. I use singleton, so my test objects should not be re-built in every testing class. Now there are some fields, such as those BaseEconomyassigned inside singleton, that I need in each test class. Thus, each test class has an initialization method similar to this:
[TestInitialize]
public void Initialize()
{
Singleton instance = Singleton.Instance
_baseDate = Singleton.BaseDate;
_baseEconomy = Singleton.BaseEconomy;
}
The string is Singleton instance = Singleton.Instancecompletely necessary for the implementation of my singleton, however I do not consider it fundamentally correct, because I never use a variable instance.
So, how do I instantiate a singleton for the sole purpose of having an instance for assigning and accessing fields for each test class? Do I really need to assign it to a variable that I will never use?
source
share