public void Promotion_CanPutAProductOnSale() { //InitBasicStubs(); var app = CreateHccAppInMemory(); var p = new Promotion(); p.IsEnabled = true; p.Name = "Product Sale Test"; p.CustomerDescription = "A Customer Discount"; p.StartDateUtc = DateTime.UtcNow.AddDays(-1); p.EndDateUtc = DateTime.UtcNow.AddDays(1); p.StoreId = 1; p.Id = 1; var prod = new Product(); prod.Bvin = "553690e2-6372-431f-97c0-83e11a05f298"; prod.SitePrice = 59.99m; app.CatalogServices.Products.Create(prod); Assert.IsTrue(p.AddQualification(new ProductBvin(prod.Bvin)), "Add Qualification Failed"); Assert.IsTrue(p.AddAction(new ProductPriceAdjustment(AmountTypes.MonetaryAmount, -20m)), "Add Action Failed"); var userPrice = new UserSpecificPrice(prod, null, app.CurrentStore.Settings); var actual = p.ApplyToProduct(app.CurrentRequestContext, prod, userPrice, null); 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"); }
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"); }
public void Promotion_CanSkipPromotionIfNoProduct() { var app = CreateHccAppInMemory(); var p = new Promotion(); p.IsEnabled = true; p.Name = "Product Sale Test"; p.StartDateUtc = DateTime.UtcNow.AddDays(-1); p.EndDateUtc = DateTime.UtcNow.AddDays(1); p.StoreId = 1; p.Id = 1; Assert.IsTrue(p.AddQualification(new ProductBvin("b991f9de-2bf2-4472-a913-bfaa08e230cf")), "Add Qualification Failed"); Assert.IsTrue(p.AddAction(new ProductPriceAdjustment(AmountTypes.MonetaryAmount, -20m)), "Add Action Failed"); var actual = p.ApplyToProduct(app.CurrentRequestContext, null, null, null); Assert.IsFalse(actual, "Promotion should not have applied"); }
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"); }