Ejemplo n.º 1
0
        public void TestSingletonChina()
        {
            TaociChina taociChina  = TaociChina.Instance;
            TaociChina taociChina1 = TaociChina.Instance;

            Assert.AreSame(taociChina, taociChina1);
        }
Ejemplo n.º 2
0
        public void TestFactoryChinaCheckNameAfterPrepare1()
        {
            TaociChina taociChina = TaociChina.Instance;

            var a = (PlateDecorator)taociChina.PurchasePlate("SmallPlate");

            a.Prepare();
            var x = a.Plate;

            Assert.AreEqual(4.50, x.price);
        }
Ejemplo n.º 3
0
        public void TestFactoryChina()
        {
            TaociChina taociChina = TaociChina.Instance;

            var a = (PlateDecorator)taociChina.PurchasePlate("SmallPlate");
            var x = a.Plate;

            Assert.AreEqual(typeof(SmallPLate), x.GetType());

            Assert.IsInstanceOf <SmallPLate>(x);
        }
Ejemplo n.º 4
0
        public void TestSingletonWithParaller()
        {
            TaociChina a = null;
            TaociChina b = null;

            Parallel.Invoke(
                () => { b = TaociChina.Instance; },
                () => { a = TaociChina.Instance; }
                );

            Assert.IsTrue(object.ReferenceEquals(a, b));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            CerluxPoland cerluxPoland = CerluxPoland.Instance;
            TaociChina   taociChina   = TaociChina.Instance;

            string[] plates = new string[] { "SmallPlate", "MediumPlate", "BigPlate", "LuxuryPlate" };

            Order orderOfPlatesCerlux = new Order();

            //Plate plate = cerluxPoland.PurchasePlate("SmallPlate");
            foreach (string p in plates)
            {
                orderOfPlatesCerlux.addItem(cerluxPoland.PurchasePlate(p));
            }

            //Console.WriteLine("Do zrobienia");

            Order orderPlatesTaoci = new Order();

            foreach (string p in plates)
            {
                orderPlatesTaoci.addItem(taociChina.PurchasePlate(p));
            }

            orderPlatesTaoci.addItem(taociChina.PurchasePlate("Vase"));


            Seller potter = new Seller();

            Console.WriteLine("Garncarz skończył pracę nad zamówieniem");
            orderOfPlatesCerlux.AttachObserver(potter);

            firing(orderOfPlatesCerlux);

            Console.WriteLine("Zrobiona ilość tależy " + PlateDecorator.NumberOfPlate + " za cenę " + PlateDecorator.PriceOfPlates1);

            Console.WriteLine("Zrobiona ilość waz " + VaseDecorator.NumberOfPlate + " za cenę " + VaseDecorator.PriceOfPlates1);
            /////////////////////////////////////////////////////////////////
            orderPlatesTaoci.AttachObserver(potter);

            firing(orderPlatesTaoci);


            Console.WriteLine("Zrobiona ilość tależy " + PlateDecorator.NumberOfPlate + " za cenę " + PlateDecorator.PriceOfPlates1);

            Console.WriteLine("Zrobiona ilość waz " + VaseDecorator.NumberOfPlate + " za cenę " + VaseDecorator.PriceOfPlates1);

            orderOfPlatesCerlux.RemoveObserver(potter);
            //firing(orderOfPlatesCerlux);


            CerluxPoland cerluxPoland1 = CerluxPoland.Instance;

            var a = (PlateDecorator)cerluxPoland1.PurchasePlate("SmallPlate");
            var x = a.Plate;

            //Assert.IsInstanceOf(typeof(SmallPLate), x.GetType());

            Console.WriteLine(x.GetType() + " " + typeof(SmallPLate));
            // Assert.

            IMyData <int> array = new MyData <int>();

            array.AddItem(5);
            array.AddItem(6);
            array.AddItem(8);

            array.Find(6);
        }