public void CanSkipPromotionIfNoProduct() { Promotion p = new Promotion(); p.IsEnabled = true; p.Name = "Product Sale Test"; p.StartDateUtc = DateTime.Now.AddDays(-1); p.EndDateUtc = DateTime.Now.AddDays(1); p.StoreId = 1; p.Id = 1; Assert.IsTrue(p.AddQualification(new ProductBvin("bvin1234")), "Add Qualification Failed"); Assert.IsTrue(p.AddAction(new ProductPriceAdjustment(AmountTypes.MonetaryAmount, -20m)), "Add Action Failed"); RequestContext c = new RequestContext(); MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c); bool actual = p.ApplyToProduct(app, null, null, null, DateTime.UtcNow); Assert.IsFalse(actual, "Promotion should not have applied"); }
public void CanPutAProductOnSale() { Promotion p = new Promotion(); p.IsEnabled = true; p.Name = "Product Sale Test"; p.CustomerDescription = "A Customer Discount"; p.StartDateUtc = DateTime.Now.AddDays(-1); p.EndDateUtc = DateTime.Now.AddDays(1); p.StoreId = 1; p.Id = 1; Assert.IsTrue(p.AddQualification(new ProductBvin("bvin1234")), "Add Qualification Failed"); Assert.IsTrue(p.AddAction(new ProductPriceAdjustment(AmountTypes.MonetaryAmount, -20m)), "Add Action Failed"); Catalog.Product prod = new Catalog.Product(); prod.Bvin = "bvin1234"; prod.SitePrice = 59.99m; prod.StoreId = 1; Catalog.UserSpecificPrice userPrice = new Catalog.UserSpecificPrice(prod, null); RequestContext c = new RequestContext(); MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c); bool actual = p.ApplyToProduct(app, prod, userPrice, null, DateTime.UtcNow); Assert.IsTrue(actual, "Promotion should have applied with return value of true"); Assert.AreEqual(39.99m, userPrice.PriceWithAdjustments(), "Price should have been reduced by $20.00"); Assert.AreEqual(p.CustomerDescription, userPrice.DiscountDetails[0].Description, "Description should match promotion"); }