public PercentagePromo(int actual, decimal price, PromotionRules promotionRules) { _actual = actual; _price = price; _promotionRules = promotionRules; SKUid = _promotionRules.SKUids; }
public void SetUp() { this.MockClient = new Mock <IClient>(); this.MockRental1 = new Mock <IRental>(); this.MockRental2 = new Mock <IRental>(); this.MockRental3 = new Mock <IRental>(); this.MockRental4 = new Mock <IRental>(); IList <IRental> rentals = new List <IRental>(); rentals.Add(this.MockRental1.Object); rentals.Add(this.MockRental2.Object); rentals.Add(this.MockRental3.Object); rentals.Add(this.MockRental4.Object); PromotionRules familyRentalRules = new PromotionRules(TestsConstants.FAMILY_RENTAL_TERMS_AND_CONDITIONS, new DateTime(TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_YEAR, TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_MONTH, TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_DAY, 0, 0, 0), new DateTime(TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_YEAR, TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_MONTH, TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_DAY, 0, 0, 0)); FamilyRentalInformation familyRentalInformation = new FamilyRentalInformation( TestsConstants.FAMILY_RENTAL_DISCOUNT_PERCENT, TestsConstants.FAMILY_RENTAL_MINIMUM_RENTALS, TestsConstants.FAMILY_RENTAL_MAXIMUM_RENTALS, familyRentalRules); this.FamilyRental = new FamilyRental(this.MockClient.Object, familyRentalInformation, rentals); }
public void GetPromotionRules_RulesAreAvailableInTheStore_ShouldNotReturnEmptyListForBothSingleAndComboRules() { //Arrange _mockDataStore.SetupGet(x => x.PromotionRules).Returns(new PromotionRules { SingleRules = new List <SinglePromoRule>() { new SinglePromoRule { Item = new PromoRuleItem { } } } , ComboRules = new List <ComboPromoRule>() { new ComboPromoRule { Items = new List <PromoRuleItem>() } } }); //Act PromotionRules result = _promoRuleDataAccessService.GetPromotionRules(); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.SingleRules.Count > 0); Assert.IsTrue(result.ComboRules.Count > 0); }
public void SetUp() { this.Client = new Client(); this.BikeSpecifications = new BikeSpecifications(TestsConstants.BIKE_BRAND, TestsConstants.BIKE_MODEL, TestsConstants.BIKE_COLOR); this.Bike = new Bike(TestsConstants.BIKE_IDENTIFICATION_CODE, this.BikeSpecifications); PromotionRules familyRentalRules = new PromotionRules(TestsConstants.FAMILY_RENTAL_TERMS_AND_CONDITIONS, new DateTime(TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_YEAR, TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_MONTH, TestsConstants.FAMILY_RENTAL_EFFECTIVE_DATE_DAY, 0, 0, 0), new DateTime(TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_YEAR, TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_MONTH, TestsConstants.FAMILY_RENTAL_EXPIRATON_DATE_DAY, 0, 0, 0)); FamilyRentalInformation familyRentalInformation = new FamilyRentalInformation( TestsConstants.FAMILY_RENTAL_DISCOUNT_PERCENT, TestsConstants.FAMILY_RENTAL_MINIMUM_RENTALS, TestsConstants.FAMILY_RENTAL_MAXIMUM_RENTALS, familyRentalRules); RentalByHour rentalByHour = new RentalByHour(new Money(TestsConstants.RENTAL_BY_HOUR_AMOUNT, TestsConstants.RENTAL_BY_HOUR_TYPE_OF_CURRENCY)); RentalByDay rentalByDay = new RentalByDay(new Money(TestsConstants.RENTAL_BY_DAY_AMOUNT, TestsConstants.RENTAL_BY_DAY_TYPE_OF_CURRENCY)); RentalByWeek rentalByWeek = new RentalByWeek(new Money(TestsConstants.RENTAL_BY_WEEK_AMOUNT, TestsConstants.RENTAL_BY_WEEK_TYPE_OF_CURRENCY)); this.RentalOperator = new RentalOperator(familyRentalInformation, rentalByHour, rentalByDay, rentalByWeek); }
public void Initialize() { //Setup //Rules section _rules = new Dictionary <char, Tuple <int, double> >(); _comboRules = new List <Tuple <char, char, double> >(); //Adding first Rule for skuid-A _rules.Add('A', new Tuple <int, double>(3, 130)); //Adding first Rule for skuid-B _rules.Add('B', new Tuple <int, double>(2, 45)); _comboRules = new List <Tuple <char, char, double> >(); //Adding combo Rule _comboRules.Add(new Tuple <char, char, double>('C', 'D', 30)); _promotionRule = new PromotionRules(_rules, _comboRules); //Master Data section productWithPrice = new Dictionary <char, double>(); productWithPrice.Add('A', 50); productWithPrice.Add('B', 30); productWithPrice.Add('C', 20); productWithPrice.Add('D', 15); _SKUCart = new SkuCart(productWithPrice); _promotionEngine = new PromotionEngine_V1(); _orderCalculator = new OrderCalculator(_promotionEngine); }
public void PromotionRules_Should_Return_45_When_BB() { PromotionRules promotionRules = new PromotionRules(); var output = promotionRules.PromotionRules_2B(new List <char>() { 'B', 'B' }); Assert.AreEqual(ApplicationConstants.B_2, output.PromotionCartPrice); }
public void PromotionRules_Should_Return_130_When_AAA() { PromotionRules promotionRules = new PromotionRules(); var output = promotionRules.PromotionRules_3A(new List <char>() { 'A', 'A', 'A' }); Assert.AreEqual(ApplicationConstants.A_3, output.PromotionCartPrice); }
public void PromotionRules_Should_Return_30_When_CD() { PromotionRules promotionRules = new PromotionRules(); var output = promotionRules.PromotionRules_CD(new List <char>() { 'C', 'D' }); Assert.AreEqual(ApplicationConstants.C_D, output.PromotionCartPrice); }
public void Bill_From0To2000_DefaultCustomers_DefaultCoupon( [Values(1, 3)] int noOfCustomer, [Values(450, 500, 600)] int price, [Values(PromotionRules.Coupon.NONE, PromotionRules.Coupon.STARCARD)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = 0; //No Discount expectedBill = totalBill - discount; expectedCouponUsed = "No coupon used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "No Rule Apply"); }
public void Bill_From0To2000_4CustomersOrMore_DIS10( [Values(4, 6, 8, 9)] int noOfCustomer, [Values(100, 180, 200)] int price, [Values(PromotionRules.Coupon.DIS10)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = totalBill * 0.1; //Discount 10% expectedBill = totalBill - discount; expectedCouponUsed = "\"DIS10\" used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "Apply Rule 1"); }
public void Bill_From2000To2500_4Customers_STARCARD( [Values(4)] int noOfCustomer, [Values(500, 550, 600)] int price, [Values(PromotionRules.Coupon.STARCARD)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = price; //come 4 pay 3 expectedBill = totalBill - discount; expectedCouponUsed = "\"STARCARD\" used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "Apply Rule 2"); }
public void Bill_From0To2000_2Customers_STARCARD( [Values(2)] int noOfCustomer, [Values(250, 350, 500, 850)] int price, [Values(PromotionRules.Coupon.STARCARD)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = totalBill * 0.3; //Discount 30% expectedBill = totalBill - discount; //No any discount expectedCouponUsed = "\"STARCARD\" used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "Apply Rule 2"); }
public void Bill_From0To2000_4CustomersOrMore_NONE( [Values(4, 6, 8, 9)] int noOfCustomer, [Values(100, 180, 200)] int price, [Values(PromotionRules.Coupon.NONE)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = 0; //No Discount expectedBill = totalBill - discount; //No any discount expectedCouponUsed = "No coupon used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "No Rule Apply"); }
public void Bill_From2500Up_DefaultCustomers_DefaultCoupon( [Values(1, 3)] int noOfCustomer, [Values(2500, 2800, 3000)] int price, [Values(PromotionRules.Coupon.STARCARD, PromotionRules.Coupon.DIS10, PromotionRules.Coupon.NONE)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = totalBill * 0.25; //discount25% expectedBill = totalBill - discount; expectedCouponUsed = "No coupon used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "Apply Rule 4"); }
//Some case "STARCARD" get equal discount same as Rule4(Total bill >=2500) So assumption to no coupon used auto apply for Rule4 public void Bill_From2500Up_4CustomersOrMore_STARCARD( [Values(4, 7, 12)] int noOfCustomer, [Values(700, 1000, 1200, 2000)] int price, [Values(PromotionRules.Coupon.STARCARD)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = totalBill * 0.25; //discount25% expectedBill = totalBill - discount; expectedCouponUsed = "No coupon used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "Apply Rule 4"); }
public void Bill_From2000To2500_DefaultCustomers_DefaultCoupon( [Values(3)] int noOfCustomer, [Values(700, 780, 800)] int price, [Values(PromotionRules.Coupon.NONE, PromotionRules.Coupon.DIS10, PromotionRules.Coupon.STARCARD)] PromotionRules.Coupon code) { totalBill = noOfCustomer * price; discount = totalBill * 0.1; //discount10% expectedBill = totalBill - discount; expectedCouponUsed = (code == PromotionRules.Coupon.DIS10) ? "\"DIS10\" used" : "No coupon used"; PromotionRules promotion = new PromotionRules().GetBill(noOfCustomer, price, code); Assert.IsTrue(expectedBill == promotion.NetBill && expectedCouponUsed == promotion.CouponUsed, "Apply Rule 1"); }
public void GetPromotionRules_NoRuleIsAddedInTheStore_ShouldReturnEmptyListForBothSingleAndComboRules() { //Arrange _mockDataStore.SetupGet(x => x.PromotionRules).Returns(new PromotionRules { SingleRules = new List <SinglePromoRule>() , ComboRules = new List <ComboPromoRule>() }); //Act PromotionRules result = _promoRuleDataAccessService.GetPromotionRules(); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.SingleRules.Count == 0); Assert.IsTrue(result.ComboRules.Count == 0); }
public decimal GetBasketValue() { InitializeCartItems(); PromotionCalculator promotionCalculator = new PromotionCalculator(_cartItems, PromotionRules.GetPromotions()); _finalValue = promotionCalculator.ComputeResult(); return(_finalValue); }
public ComboPromo(string[] comboStr, PromotionRules promotionRules) { _comboStr = comboStr; _promotionRules = promotionRules; SKUid = _promotionRules.SKUids; }
public CountPromo(int actual, PromotionRules promotionRules) { _actual = actual; _promotionRules = promotionRules; SKUid = _promotionRules.SKUids; }