Esempio n. 1
0
        public void OneInstance()
        {
            var s1 = GlobalSingleton.Instance();
            var s2 = GlobalSingleton.Instance();

            Assert.That(s1, Is.EqualTo(s2));
        }
Esempio n. 2
0
        public void OneGlobalInstance()
        {
            GlobalSingleton s1 = null;
            GlobalSingleton s2 = null;

            var thread1 = new Thread(() => s1 = GlobalSingleton.Instance());
            var thread2 = new Thread(() => s2 = GlobalSingleton.Instance());

            thread1.Start();
            thread2.Start();

            thread1.Join();
            thread2.Join();

            Assert.That(s1, Is.EqualTo(s2));
        }