private DiscountOfProducts return15(ShoppingBasket arg) { var d = new DiscountOfProducts(); d.AddProduct(product.Id, product.Price - 15); d.Discount = 15; return(d); }
public DiscountOfProducts return10(ShoppingBasket shoppingBasket) { var d = new DiscountOfProducts(); d.AddProduct(product1.Id, 0.9 * product1.Price); d.Discount = 0.1 * product1.Price; return(d); }
public DiscountOfProducts return200(ShoppingBasket shoppingBasket) { var d = new DiscountOfProducts(); d.AddProduct(product1.Id, product1.Price); d.Discount = 200; return(d); }
public DiscountCalculatorTests() { User u = new User(); Store store = new Store("teststore", new CreditCard("1", "1", "1", "1", "1", "1"), new Address("1", "1", "1", "1", "1")); this.shoppingBasket = new ShoppingBasket(new ShoppingCart(u), store); d1 = new DiscountOfProducts(); d1.Discount = 15; d2 = new DiscountOfProducts(); d2.Discount = 20; }
private DiscountOfProducts Calc(ShoppingBasket basket, double percent) { var ret = new DiscountOfProducts(); double discount = 0; foreach (var p_q in basket.GetDictionaryProductQuantity()) { var product = p_q.product; var quantity = p_q.quantity; discount += quantity * product.Price * percent; ret.Products.Add(product.Id, (1 - percent) * product.Price); } ret.Discount = discount; return(ret); }
public DiscountTests() { discountCalc1 = new Mock <IDiscountCalculator>(); discountCalc2 = new Mock <IDiscountCalculator>(); var d1 = new DiscountOfProducts(); d1.Discount = 15; var d2 = new DiscountOfProducts(); d2.Discount = 20; discountCalc1.Setup(d => d.CalcDiscount(It.IsAny <ShoppingBasket>())).Returns(d1); discountCalc1.Setup(d => d.GetFunction()).Returns(new Func <ShoppingBasket, DiscountOfProducts>((ShoppingBasket shoppingBasket) => d1)); discountCalc2.Setup(d => d.CalcDiscount(It.IsAny <ShoppingBasket>())).Returns(d2); discountCalc2.Setup(d => d.GetFunction()).Returns(new Func <ShoppingBasket, DiscountOfProducts>((ShoppingBasket shoppingBasket) => d2)); User u = new User(); Store store = new Store("teststore", new CreditCard("1", "1", "1", "1", "1", "1"), new Address("1", "1", "1", "1", "1")); this.shoppingBasket = new ShoppingBasket(new ShoppingCart(u), store); }