public void CategoryDiscount_ProductDiscountDisabled() { //Arrange Brand brand = new Brand(1, "b1"); Category category = new Category(1, "c1"); Product p1 = new Product("p1", 800, 700, brand, category); Brand brand2 = new Brand(2, "b2"); Category category2 = new Category(2, "c2"); Product p2 = new Product("p2", 400, 250, brand2, category2); User u = new User("user", MemberShipTypeEnum.GOLD); Basket = new Basket(u, DateTime.Now); Basket.AddOrderProduct(new BasketProduct(p1, 1)); Basket.AddOrderProduct(new BasketProduct(p2, 1)); Dictionary <int, Double> categoryDiscounts = new Dictionary <int, double> { { 1, 0.1 }, { 3, 0.15 } }; DiscountBase productDiscountStrategy = new ProductDiscount(false); DiscountBase categoryDiscountStrategy = new CategoryDiscount(categoryDiscounts, productDiscountStrategy); DiscountBase memberShipDiscountStrategy = new BasketDiscountGoldUser(categoryDiscountStrategy); double discountedPrice = Basket.calcDiscountedTotal(memberShipDiscountStrategy); //Act //800+400 =1200 total after product discount //1200 - 80 = 1120 total after category discount //1120 - 112 = 783 total after gold membership discount discountedPrice.Should().Be(1008); }
public void BasketDiscountOverGoldMemberShipType() { //Arrange Product p1 = new Product("p1", 800, 700); Product p2 = new Product("p2", 400, 250); User u = new User("user", MemberShipTypeEnum.GOLD); Basket = new Basket(u, DateTime.Now); Basket.AddOrderProduct(new BasketProduct(p1, 1)); Basket.AddOrderProduct(new BasketProduct(p2, 1)); //Act DiscountBase productDiscountStrategy = new ProductDiscount(); DiscountBase memberShipDiscountStrategy = new BasketDiscountGoldUser(productDiscountStrategy); double discountedPrice = Basket.calcDiscountedTotal(memberShipDiscountStrategy); //Assert discountedPrice.Should().Be(855); }