Example #1
0
        public void TestMethod1(string id, string type)
        {
            Shape shape = ShapeCache.GetShape(id);

            Assert.AreEqual(id, shape.ID);
            Assert.AreEqual(type, shape.Type);
        }
Example #2
0
        static void Main(string[] args)
        {
            #region Builder Pattern
            Console.WriteLine("-------Builder Pattern--------");
            MealBuilder mb = new MealBuilder();

            Meal Vegan = mb.PrepareVegMeal();
            Console.WriteLine("Preparing...Vegan");
            Vegan.ShowItems();
            Console.WriteLine("Cost:{0}", Vegan.GetCost());


            MealBuilder mbu = new MealBuilder();

            Meal HardCode = mb.PrepareNonVegMeal();
            Console.WriteLine("Preparing...Hard");
            Vegan.ShowItems();
            Console.WriteLine("Cost:{0}", HardCode.GetCost());
            #endregion
            Console.WriteLine("---------------------------");


            Console.WriteLine("-------ProtoType Pattern---------");
            ShapeCache.LoadCache();

            ProtoProj.Shape clonedShape = (ProtoProj.Shape)ShapeCache.GetShape("1");
            Console.WriteLine("Shape: {0}", clonedShape.GetType());

            ProtoProj.Shape clonedShape1 = (ProtoProj.Shape)ShapeCache.GetShape("2");
            Console.WriteLine("Shape: {0}", clonedShape1.GetType());

            ProtoProj.Shape clonedShape2 = (ProtoProj.Shape)ShapeCache.GetShape("3");
            Console.WriteLine("Shape: {0}", clonedShape2.GetType());


            Console.WriteLine("-------Adapter Pattern------");

            AudioPlayer ap = new AudioPlayer();
            ap.Play("mp4", "alone.mp4");
            ap.Play("mp3", "more_than_words.mp3");
            ap.Play("vlx", "beyond_horizon.vlc");

            Console.WriteLine("-----Bridge Pattern------");

            BridgeProj.Shape red   = new BridgeProj.Circle(new RedCircle(), 100, 100, 100);
            BridgeProj.Shape green = new BridgeProj.Circle(new GreenCircle(), 100, 100, 100);

            red.Draw();
            green.Draw();

            Console.WriteLine("---------------------------");



            Console.ReadKey();
        }
Example #3
0
        public static void Start()
        {
            ShapeCache.LoadCache();

            Creational.Prototype.shapes.Shape clonedShape = ShapeCache.GetShape("1");
            Console.WriteLine($"Shape : {clonedShape.Type}");

            Creational.Prototype.shapes.Shape clonedShape2 = ShapeCache.GetShape("2");
            Console.WriteLine($"Shape : {clonedShape2.Type}");

            Creational.Prototype.shapes.Shape clonedShape3 = ShapeCache.GetShape("3");
            Console.WriteLine($"Shape : {clonedShape3.Type}");
        }
Example #4
0
    public void Main()
    {
        ShapeCache.LoadCache();

        Shape cloneShape = ShapeCache.GetShape("1");

        Console.WriteLine("shape type::" + cloneShape.GetShapeType());

        Shape cloneShape2 = ShapeCache.GetShape("2");

        Console.WriteLine("shape type::" + cloneShape2.GetShapeType());

        Shape cloneShape3 = ShapeCache.GetShape("3");

        Console.WriteLine("shape type::" + cloneShape3.GetShapeType());
    }
Example #5
0
        static void Main(string[] args)
        {
            ShapeCache.LoadCache();

            Shape clonedShape = (Shape)ShapeCache.GetShape("1");

            Console.WriteLine("Shape : " + clonedShape.Type);
            clonedShape.Draw();

            Shape clonedShape2 = (Shape)ShapeCache.GetShape("2");

            Console.WriteLine("Shape : " + clonedShape2.Type);
            clonedShape2.Draw();

            Shape clonedShape3 = (Shape)ShapeCache.GetShape("3");

            Console.WriteLine("Shape : " + clonedShape3.Type);
            clonedShape3.Draw();

            Console.ReadKey();
        }
Example #6
0
 public void TestMethod2()
 {
     Assert.ThrowsException <KeyNotFoundException>(() => ShapeCache.GetShape("4"));
 }