public void MultibuyOnlyOneRelatedProducts() { ISpecialOffer offer = new MultibuyOffer("Beans", 2, "Soup", 1); var discountProduct = offer.DetermineSpecialOffer(_products); Assert.IsNull(discountProduct); }
public void MultibuyBothRelatedProductsNotEnoughRequired() { //need two beans to get the offer, so shouldn't give an offer ISpecialOffer offer = new MultibuyOffer("Beans", 2, "Eggs", 1); var discountProduct = offer.DetermineSpecialOffer(_products); Assert.IsNull(discountProduct); }
public void MultibuyNoRelatedProducts() { //no products involved in the deal in the list ISpecialOffer offer = new MultibuyOffer("Soup", 2, "Milk", 1); var discountProduct = offer.DetermineSpecialOffer(_products); Assert.IsNull(discountProduct); }
public void MultibuyConstructorTest() { var productName = "Cheese"; var numberNeeded = 1; var offer = new MultibuyOffer(productName, numberNeeded); Assert.AreEqual(productName, offer.ProductName); Assert.AreEqual(numberNeeded, offer.NumRequired); }
public void MultibuyBothRelatedProductsMultipleProductsOffer() { //have two beans, can get two eggs discounted, two eggs are present so should get two eggs discounted var _twoBeansTwoEggs = new List <Product>() { new Product("Beans", 0.9m), new Product("Beans", 0.9m), new Product("Eggs", 0.3m), new Product("Eggs", 0.3m) }; ISpecialOffer offer = new MultibuyOffer("Beans", 2, "Eggs", 2); var discountProduct = offer.DetermineSpecialOffer(_twoBeansTwoEggs); Assert.AreEqual <decimal>(-0.6m, discountProduct.Price); Assert.AreEqual("Discount on Eggs", discountProduct.ProductName); }
public void MultibuyBothRelatedProductsMorePresentThanOffer() { //have two beans, can get one egg discounted even though two eggs are present var _twoBeansTwoEggs = new List <Product>() { new Product("Beans", 0.9m), new Product("Beans", 0.9m), new Product("Eggs", 0.3m), new Product("Eggs", 0.3m) }; ISpecialOffer offer = new MultibuyOffer("Beans", 2, "Eggs", 1); var discountProduct = offer.DetermineSpecialOffer(_twoBeansTwoEggs); Assert.AreEqual <decimal>(-0.3m, discountProduct.Price); Assert.AreEqual("Discount on Eggs", discountProduct.ProductName); }
public void MultibuyBothRelatedProductsMoreOfferThanPresent() { //have two beans, could get two eggs discounted, but only one egg is present //thus only one egg is discounted var _twoBeansOneEggs = new List <Product>() { new Product("Beans", 0.9m), new Product("Beans", 0.9m), new Product("Eggs", 0.3m) }; ISpecialOffer offer = new MultibuyOffer("Beans", 2, "Eggs", 2); var discountProduct = offer.DetermineSpecialOffer(_twoBeansOneEggs); Assert.AreEqual <decimal>(-0.3m, discountProduct.Price); Assert.AreEqual("Discount on Eggs", discountProduct.ProductName); }
public void MultibuyNoOfferTest(int cheeseCount) { var productName = "Cheese"; var numberNeeded = 3; var offer = new MultibuyOffer(productName, numberNeeded); var products = new Dictionary <Product, int>(); products.Add(new Product("Cheese", 0.5m), cheeseCount); var discountedProduct = offer.DetermineSpecialOffer(products); Assert.IsNull(discountedProduct); }
protected override Constants.ProcessOutcome Process() { var fileName = String.Format(Settings.Default.FileName, DateTime.Now.AddDays(Settings.Default.FileNameDateCheckOffsetDays).ToString("yyyyMMdd")); importer = new MultibuyOffer(Settings.Default.FilePath, Settings.Default.ArchivePath, Settings.Default.StagingTableName, Settings.Default.FormatFilePath, fileName, Settings.Default.SummaryReportErrorToEmailAddress, Settings.Default.SummaryReportFromEmailAddress, Settings.Default.SummaryReportFromAddressFriendlyName, Settings.Default.SqlaServerPath, Settings.Default.SqlbServerPath, Settings.Default.LocalSqlPath, Settings.Default.TemporaryUploadFolder, Settings.Default.DaysToRun); return(importer.Process()); }
public void MultibuyDetermineOfferTest(int cheeseCount, decimal expectedDiscountValue) { var productName = "Cheese"; var numberNeeded = 3; var offer = new MultibuyOffer(productName, numberNeeded); var products = new Dictionary <Product, int>(); products.Add(new Product("Cheese", 0.5m), cheeseCount); var expectedDiscountProduct = new Product("Cheese Multibuy", expectedDiscountValue); var discountedProduct = offer.DetermineSpecialOffer(products); Assert.AreEqual(expectedDiscountProduct, discountedProduct); }
private void InitAllOffers() { var startThisWeek = new DateTime(2018, 03, 25); var endThisWeek = new DateTime(2018, 04, 1); _offers = new List <SpecialOfferDuration>(); //TODO: move this function out of the code so Offers can be dynamically added var appleOffer = new DiscountOffer("Apples", 0.1m); var soupOffer = new MultibuyOffer("Soup", 2, "Bread", 0.5m); _offers.Add(new SpecialOfferDuration() { StartDate = startThisWeek, EndDate = endThisWeek, SpecialOffer = appleOffer }); _offers.Add(new SpecialOfferDuration() { StartDate = startThisWeek, EndDate = endThisWeek, SpecialOffer = soupOffer }); }