Пример #1
0
        static void Main(string[] args)
        {
            Approver Dariusz = new HeadChef();
            Approver Jacek   = new GeneralManager();
            Approver Michal  = new PurchasingManager();

            Dariusz.SetSupervisor(Jacek);
            Jacek.SetSupervisor(Michal);

            PurchaseOrder order1 = new PurchaseOrder(1, 20, 30, "Product");

            Dariusz.ProcessRequest(order1);

            PurchaseOrder order2 = new PurchaseOrder(1, 20, 1300, "Product");

            Dariusz.ProcessRequest(order2);

            PurchaseOrder order3 = new PurchaseOrder(1, 20, 3500, "Product");

            Dariusz.ProcessRequest(order3);

            PurchaseOrder order4 = new PurchaseOrder(1, 20, 130000, "Product");

            Dariusz.ProcessRequest(order4);


            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Create the chain links
            Approver jennifer = new HeadChef();
            Approver mitchell = new PurchasingManager();
            Approver olivia   = new GeneralManager();

            //Create the chain
            jennifer.SetSupervisor(mitchell);
            mitchell.SetSupervisor(olivia);

            // Generate and process purchase requests
            var p = new PurchaseOrder(1, 20, 69, "Spices");

            jennifer.ProcessRequest(p);

            p = new PurchaseOrder(2, 300, 1389, "Fresh Veggies");
            jennifer.ProcessRequest(p);

            p = new PurchaseOrder(3, 500, 4823.99, "Beef");
            jennifer.ProcessRequest(p);

            p = new PurchaseOrder(4, 4, 12099, "Ovens");
            jennifer.ProcessRequest(p);

            // Wait for user
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Approver a = new HeadChef();
            Approver b = new Manager();
            Approver c = new Director();

            a.SetSupervisor(b);
            b.SetSupervisor(c);

            PurchaseOrder order = new PurchaseOrder(1, "Stacy", 2.50, 680);

            a.ProcessRequest(order);

            order = new PurchaseOrder(4, "Sam", 4.00, 12500);
            a.ProcessRequest(order);

            order = new PurchaseOrder(9, "Samantha", 2.75, 3000);
            a.ProcessRequest(order);
        }
        public void AprroveOrder_With_Design()
        {
            //Create the chain links
            Approver jennifer = new HeadChef();
            Approver mitchell = new PurchasingManager();
            Approver olivia   = new GeneralManager();

            //Create the chain can be change at runtime
            jennifer.SetSupervisor(mitchell);
            mitchell.SetSupervisor(olivia);

            // Generate and process purchase requests
            var p = new PurchaseOrder(2, 300, 1389, "Fresh Veggies");

            //Act
            jennifer.ValidatePurchaseOrder(p);

            //Assert
            Assert.True(p.HasbeenValidated);
        }