static void Main(string[] args)
        {
            Client client = new Client();

            // This way the client code can support the simple leaf
            // components...
            Leaf leaf = new Leaf();

            Console.WriteLine("Client: I get a simple component:");
            client.ClientCode(leaf);

            // ...as well as the complex composites.
            Composite tree    = new Composite();
            Composite branch1 = new Composite();

            branch1.Add(new Leaf());
            branch1.Add(new Leaf());
            Composite branch2 = new Composite();

            branch2.Add(new Leaf());
            tree.Add(branch1);
            tree.Add(branch2);
            Console.WriteLine("Client: Now I've got a composite tree:");
            client.ClientCode(tree);

            Console.Write("Client: I don't need to check the components classes even when managing the tree:\n");
            client.ClientCode2(tree, leaf);
        }
        public void Test()
        {
            var compositeA = new Composite("CompositeA");

            compositeA.Add(new Leaf("LeafA"));
            compositeA.Add(new Leaf("LeafB"));

            var compositeB = new Composite("CompositeB");

            compositeB.Add(new Leaf("LeafC"));
            compositeB.Add(new Leaf("LeafD"));

            compositeA.Add(compositeB);

            Console.WriteLine(compositeA);
        }
        public void CompositeUsage()
        {
            IComponent c1 = new Leaf();
            IComponent c2 = new Leaf();
            IComponent c3 = new Leaf();

            DesignPatterns.Structural.Composite.Composite composite = new DesignPatterns.Structural.Composite.Composite(c1, c2);
            composite.Add(c3);

            composite.Operation();

            Assert.IsTrue(true);
        }