예제 #1
0
        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");
        }
예제 #2
0
        public void CanPutAProductOnSalePricedByApp()
        {
            RequestContext           c   = new RequestContext();
            MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);

            app.CurrentStore    = new Accounts.Store();
            app.CurrentStore.Id = 1;

            // Create a Promotion to Test
            Promotion p = new Promotion();

            p.Mode                = PromotionType.Sale;
            p.IsEnabled           = true;
            p.Name                = "Product Sale Test";
            p.CustomerDescription = "$10.00 off Test Sale!";
            p.StartDateUtc        = DateTime.Now.AddDays(-1);
            p.EndDateUtc          = DateTime.Now.AddDays(1);
            p.StoreId             = 1;
            p.Id = 0;
            p.AddQualification(new ProductBvin("bvin1234"));
            p.AddAction(new ProductPriceAdjustment(AmountTypes.MonetaryAmount, -10m));
            app.MarketingServices.Promotions.Create(p);

            // Create a test Product
            Catalog.Product prod = new Catalog.Product();
            prod.Bvin      = "bvin1234";
            prod.SitePrice = 59.99m;
            prod.StoreId   = 1;

            Catalog.UserSpecificPrice actualPrice = app.PriceProduct(prod, null, null);

            Assert.IsNotNull(actualPrice, "Price should not be null");
            Assert.AreEqual(49.99m, actualPrice.PriceWithAdjustments(), "Price should be $49.99");
            Assert.AreEqual(1, actualPrice.DiscountDetails.Count, "Discount Details count should be one");
            Assert.AreEqual(p.CustomerDescription, actualPrice.DiscountDetails[0].Description, "Description should match promotion");
        }
예제 #3
0
        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");
        }