예제 #1
0
        public void calculate_student_discount()
        {
            var discountCalculator = new DiscountProvider();
            var studentDiscount    = discountCalculator.Discount("Student");

            Assert.AreEqual(typeof(StudentDiscount), studentDiscount.GetType());
        }
예제 #2
0
        public void calculate_member_discount()
        {
            var discountCalculator = new DiscountProvider();
            var memeberDiscount    = discountCalculator.Discount("Member");

            Assert.AreEqual(typeof(MemberDiscount), memeberDiscount.GetType());
        }
예제 #3
0
        private static void RunSPRGood()
        {
            Product lProduct = new Product
            {
                Price = 150,
                Units = 15,
                Name  = "Watermelon"
            };
            DiscountProvider discountProvider = new DiscountProvider();
            ProfitCalculator profitCalculator = new ProfitCalculator(0.2, 90);

            ProductDisplayer.DisplayProduct(lProduct);
            lProduct.Price -= discountProvider.ApplyDiscount(profitCalculator.CalculateProfit(lProduct.Price));
            lProduct.SellProduct(1);
            ProductDisplayer.DisplayProduct(lProduct);
            lProduct.Price -= discountProvider.ApplyDiscount(profitCalculator.CalculateProfit(lProduct.Price));
            lProduct.SellProduct(2);
            profitCalculator.Tax = 0.1;
            ProductDisplayer.DisplayProduct(lProduct);
            lProduct.Price -= discountProvider.ApplyDiscount(profitCalculator.CalculateProfit(lProduct.Price));
            lProduct.SellProduct(3);
            ProductDisplayer.DisplayProduct(lProduct);
            lProduct.Price -= discountProvider.ApplyDiscount(profitCalculator.CalculateProfit(lProduct.Price));
            lProduct.SellProduct(2);
        }
예제 #4
0
파일: Program.cs 프로젝트: MshDb/test
        static void Main()
        {
            Console.WriteLine("Hello YouScan!");

            var priceProvider = new PriceProvider();

            priceProvider.SetPricing(
                new List <Price>
            {
                new Price {
                    Name = "A", ItemPrice = 125m, Volumes = new Dictionary <int, decimal> {
                        { 3, 300 }
                    }
                },
                new Price {
                    Name = "B", ItemPrice = 425m
                },
                new Price {
                    Name = "C", ItemPrice = 100, Volumes = new Dictionary <int, decimal> {
                        { 6, 500 }
                    }
                },
                new Price {
                    Name = "D", ItemPrice = 75m
                }
            });

            var discountProvider = new DiscountProvider();

            discountProvider.SetDicountTable(
                new List <DiscountSet>
            {
                new DiscountSet {
                    StartingValue = 1000, Discount = 1
                },
                new DiscountSet {
                    StartingValue = 2000, Discount = 3
                },
                new DiscountSet {
                    StartingValue = 5000, Discount = 5
                },
                new DiscountSet {
                    StartingValue = 9999, Discount = 7
                }
            });


            _terminal = new PointOfSaleTerminal(priceProvider, new DiscountCardRepository(), discountProvider);

            Run("ABCDABA");
            Run("CCCCCCC");
            Run("ABCD");
        }
예제 #5
0
 public DiscountProviderTests()
 {
     _sut = new DiscountProvider();
     _sut.SetDicountTable(
         new List <DiscountSet>
     {
         new DiscountSet {
             StartingValue = 1000, Discount = 1
         },
         new DiscountSet {
             StartingValue = 2000, Discount = 3
         },
         new DiscountSet {
             StartingValue = 5000, Discount = 5
         },
         new DiscountSet {
             StartingValue = 9999, Discount = 7
         }
     });
 }
예제 #6
0
 public void Setup()
 {
     _tshirtPriceProvider = new TshirtPriceProvider();
     _discountProvider    = new DiscountProvider();
 }
 public DiscountProviderTests()
 {
     _discountProvider = new DiscountProvider();
 }