views:

63

answers:

2

How to write test in Nunit to test that only one instance is created by my singleton class.

+5  A: 
var first = MySingleton.Instance;
var second = MySingleton.Instance;
Assert.AreSame(first, second);
Randolpho
Thanks Randolpho.It helped me a lot.
+1  A: 

Create the object twice and use Assert to make sure they have the same reference

Dror Helper