コード例 #1
0
        public void GetPriceStrategyTest()
        {
            Customer dewd = new Person();
            dewd.Name = "Åke";
            dewd.Address = "Åkerivägen 3";

            Customer leetCrusaders = new Company();
            leetCrusaders.Name = "Åkes Åkeri";
            leetCrusaders.Address = "Åkerivägen 3a";
            ((Company)leetCrusaders).ContactPerson = (Person)dewd;

            Order o2 = new Order();
            o2.Customer = leetCrusaders;

            o2.Items = new Dictionary<int, OrderLineItem>();
            Item realTruck = new Item();
            realTruck.Description = "A real truck.4 wheels and a engine and everything. Color is red";

            realTruck.Quantity = 1;
            realTruck.Price = 10000;

            o2.Items.Add(0, new OrderLineItem());
            o2.Items[0].Item = realTruck;
            o2.Items[0].Quantity = 1;

            IPriceStrategy ips = PriceStrategyFactory.GetPriceStrategy(o2);

            Assert.IsInstanceOfType(ips,typeof(BestForCustomer));
            decimal temp = o2.Total;
            temp =temp - 0.25m*temp;
            decimal temp2 = ips.GetTotal(o2);
            Assert.AreEqual(ips.GetTotal(o2), temp);
        }
コード例 #2
0
 public decimal GetTotal(Order order)
 {
     if (order.Total > Threshold)
     {
         return order.Total - Discount;
     }
     return 0;
 }
コード例 #3
0
        public static IPriceStrategy GetPriceStrategy(Order order)
        {
            CompositePriceStrategy ips;

            if (order.Customer is Company)
                {

                ips = Bfc;
                ips.Add(Pd);
                }
            else
            {
                ips = Bfs;
            }
            ips.Add(TenThousandThresholdDiscount);
            ips.Add(ThousandThresholdDiscount);

            return ips;
        }
コード例 #4
0
 public abstract decimal GetTotal(Order order);
コード例 #5
0
 public override decimal GetTotal(Order order)
 {
     return priceStrategyList.Min(x => x.GetTotal(order));
 }
コード例 #6
0
 public decimal GetTotal(Order order)
 {
     return order.Total-(order.Total* Procent);
 }
コード例 #7
0
 public decimal GetTotal(Order order)
 {
     return order.Total-Value;
 }