public void ShouldRecogniseWhenCannotUseEarlyBirdPricing() { Product _sut = new Product { Price = 10, EarlyBirdPrice = 5, EarlyBirdPriceCutOffDate = DateTime.Now.AddDays(-5) }; Assert.AreEqual(false, _sut.CanUseEarlyBirdPrice()); }
public Product CreateBespokePrice(Product product, int quantity) { if (product.StartDate == null || product.FinishDate == null) { throw new InvalidDataException("Cannot create pricing: start and finish date must not be null"); } TimeSpan spanOfDays = (DateTime)product.FinishDate - (DateTime)product.StartDate; double numberOfNights = spanOfDays.TotalDays; int numberOfCostedNights = Convert.ToInt32(numberOfNights - (Math.Floor((numberOfNights/4)))); product.Price = product.Price*numberOfCostedNights; if (product.CanUseEarlyBirdPrice()) product.EarlyBirdPrice = (decimal) product.EarlyBirdPrice*numberOfCostedNights; return product; }
public void ShouldRecogniseWhenCanUseEarlyBirdPricingOnCutOffDay() { Product _sut = new Product { Price = 10, EarlyBirdPrice = 5, EarlyBirdPriceCutOffDate = DateTime.Now }; Assert.AreEqual(true, _sut.CanUseEarlyBirdPrice()); }