开发者

Testing the existence of single instance -Singleton-C#

开发者 https://www.devze.com 2022-12-25 02:25 出处:网络
How to write test in Nunit to test that only one instance is creat开发者_运维问答ed by my singleton class.var first = MySingleton.Instance;

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

0

精彩评论

暂无评论...
验证码 换一张
取 消