示例#1
0
        public void SingletonInstanceValuesMatchTest()
        {
            SingletonClass singleton1 = SingletonClass.GetInstance();
            SingletonClass singleton2 = SingletonClass.GetInstance();

            Assert.AreEqual(singleton1.GetValue(), singleton2.GetValue());
        }
示例#2
0
        public void SingletonInstanceMatchTest()
        {
            SingletonClass singleton1 = SingletonClass.GetInstance();
            SingletonClass singleton2 = SingletonClass.GetInstance();

            Assert.AreSame(singleton1, singleton2);
        }
        public void CreateTwoInstances_SameInstanceReturnedInBothCalls()
        {
            var firstInstance  = SingletonClass.GetInstance();
            var secondInstance = SingletonClass.GetInstance();

            Assert.Same(firstInstance, secondInstance);
        }
        static void Main(string[] args)
        {
            // first with property initialization
            SingletonClass.GetInstance();

            // second with already initialized value
            SingletonClass.GetInstance();
        }
示例#5
0
        public void SingletonCreateTest()
        {
            SingletonClass singleton = SingletonClass.GetInstance();

            Assert.IsInstanceOfType(singleton, typeof(SingletonClass));
        }
        public void CreateInstance()
        {
            SingletonClass instance = SingletonClass.GetInstance();

            Assert.NotNull(instance);
        }