public static void Start()
        {
            ChocolateBoiler boiler = ChocolateBoiler.GetInstance();

            boiler.Fill();
            boiler.Boil();
            boiler.Drain();
        }
        public void TestInstanceCount()
        {
            ChocolateBoiler.GetInstance();
            ChocolateBoiler.GetInstance();
            var instance = ChocolateBoiler.GetInstance();

            Assert.AreEqual(1, ChocolateBoiler.count);
            instance.Fill();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            ChocolateBoiler chocolateBoiler = new ChocolateBoiler();

            chocolateBoiler.GetInstance();
            chocolateBoiler.Fill();
            chocolateBoiler.Boil();
            chocolateBoiler.Drain();

            Console.ReadLine();
        }
Exemple #4
0
        /// <summary>
        /// O padrão Singleton garante que uma classe tenha apenas uma instância e fornece um ponto global de acesso a ela.
        /// </summary>
        private static void TestSingleton()
        {
            ChocolateBoiler boilerReference1 = ChocolateBoiler.GetInstance();
            ChocolateBoiler boilerReference2 = ChocolateBoiler.GetInstance();

            boilerReference1.Fill();
            boilerReference2.Fill();

            boilerReference1.Drain();

            boilerReference2.Boil();

            boilerReference1.Drain();
        }
Exemple #5
0
        static void Main()
        {
            CheckNull();

            ChocolateBoiler boiler = ChocolateBoiler.GetInstance();

            CheckNull();

            //should work correct
            boiler.Fill();
            boiler.Boil();
            boiler.Drain();

            Console.WriteLine("\n");

            //should work incorrect
            boiler.Boil();
            boiler.Drain();
            boiler.Fill();
            boiler.Fill();
            boiler.Drain();

            Console.ReadKey();
        }