1

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

2 Answers 2

6
var first = MySingleton.Instance;
var second = MySingleton.Instance;
Assert.AreSame(first, second);
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.