コード例 #1
0
        public void CallMultiThreadSingeltonObject_ShouldReturnOneInstance()
        {
            var account = new Account();
            Thread tid1 = new Thread(new ThreadStart(account.GetCreationTime) );

            var account2 = new Account();
            Thread tid2 = new Thread(new ThreadStart(account2.GetCreationTime));

               tid1.Start();
               tid2.Start();

            Assert.That(account.creationTime, Is.EqualTo(account2.creationTime));
        }
コード例 #2
0
        public void CallSingeltonObject_ShouldReturnOneInstance()
        {
            var account = new Account();
            account.GetCreationTime();
            string creationTime = account.creationTime;
            Thread.Sleep(1000);

            account.GetCreationTime();
            string creationTime2 = account.creationTime;
            Assert.That(creationTime, Is.EqualTo(creationTime2));
        }