Testing the existence of single instance -Singleton-C#
How to write test in Nunit to test that only one instance is creat开发者_运维问答ed by my singleton class.
var first = MySingleton.Instance;
var second = MySingleton.Instance;
Assert.AreSame(first, second);
Create the object twice and use Assert to make sure they have the same reference
精彩评论