private bool RunTest(double amount, double expectedResult) { Discounter app = new Discounter(RepositoryFactory.GetMockRateRepository()); var result = app.Discount(amount); return(result == expectedResult); }
//since the task given says "Family Rental, is a promotion that can include from 3 to 5 Rentals (of any type) with a discount //of 30% of the total price" am going to take it literally and only apply the discount if the amount of bikes(or items for that matter) //are more or equal than 3 and less or equal than 5 public double ApplyDiscount(Discounter discounter) { if (Items.Count >= 3 && Items.Count <= 5) { return((double)discounter.DiscountStrategy[DiscountType.Value].DynamicInvoke(GrossTotal)); } else { return(GrossTotal); } }
public static Discounter Discounter() { IDiscount twoBookDiscount = new BookDiscount(2, 5); IDiscount threeBookDiscount = new BookDiscount(3, 10); IDiscount fourBookDiscount = new BookDiscount(4, 20); IDiscount fiveBookDiscount = new BookDiscount(5, 25); IEnumerable <IDiscount> discounts = new List <IDiscount> { twoBookDiscount, threeBookDiscount, fourBookDiscount, fiveBookDiscount }; var discounter = new Discounter(discounts, 8M, 5); return(discounter); }
public void When_Two_Different_Books_Two_Discount_IsApplied() { var philosophersStone = new Book(OneBookPrice, "978-1408855652"); var chamberOfSecrets = new Book(OneBookPrice, "978-1408855669"); IEnumerable <Book> books = new List <Book> { philosophersStone, chamberOfSecrets }; IDiscount oneBookDiscount = new OneBookDiscount(1); IDiscount twoBookDiscount = new TwoBookDiscount(2); IEnumerable <IDiscount> discounts = new List <IDiscount> { oneBookDiscount, twoBookDiscount }; var discounter = new Discounter(discounts); discounter.Apply(books); }
public Order(IEnumerable <IDiscountRule> discountRules) { _books = new List <Book>(); _discounter = new Discounter(discountRules); }
internal Bill ApplyDiscounts(Discounter discounter) { var discounts = discounter.CalculateDiscounts(_boughtProducts); return(new Bill(_boughtProducts, discounts.ToList())); }
public DiscountViewAdapter() { _app = new Discounter(RepositoryFactory.GetRateRepository()); }
public DiscountViewAdapter(IRateRepository repository) { _app = new Discounter(repository); }