Esempio n. 1
0
        private static void Main(string[] args)
        {
            //Cria uma venda
            var sale = new Sale(1000, PaymentMethodEnum.Money);

            var discount = new Discount();

            Console.WriteLine($"-----------------------------Payment method: {sale.PaymentMethodEnum.ToString()}-----------------------------");

            Console.WriteLine($"Amount: {sale.Amount}");

            Console.WriteLine($"Discount: {discount.Calculate(sale)}");


            //Cria uma venda
            var sale2 = new Sale(550, PaymentMethodEnum.Card);

            Console.WriteLine($"-----------------------------Payment method: {sale2.PaymentMethodEnum.ToString()}-----------------------------");

            Console.WriteLine($"Amount: {sale2.Amount}");

            Console.WriteLine($"Discount: {discount.Calculate(sale2)}");

            Console.ReadKey();
        }
Esempio n. 2
0
        public void CalculateTest(int qa, int qb, int qc, int qd, double exp)
        {
            List <Order> order = new List <Order>();

            order.Add(new Order(pa.ProdName, qa));
            order.Add(new Order(pb.ProdName, qb));
            order.Add(new Order(pc.ProdName, qc));
            order.Add(new Order(pd.ProdName, qd));
            Discount discount = new Discount();

            double total = discount.Calculate(promotion, order);

            Assert.AreEqual(total, exp);
        }
Esempio n. 3
0
        public void Discount_Price_Should_Be_The_Same_Time_Out_Of_Dated()
        {
            var priceExpected = 100;

            var customerMock = new Mock <ICustomer>();

            customerMock.Setup(x => x.Spent).Returns(2500);
            customerMock.Setup(x => x.IsDiscountAgreement).Returns(true);
            var discount = new Discount(customerMock.Object)
            {
                Price     = 100,
                ValidFrom = DateTime.Now.AddDays(-2),
                ValidTo   = DateTime.Now.AddDays(-1),
            };

            _ = discount.Calculate();
            Assert.AreEqual(priceExpected, discount.Price);
        }