Esempio n. 1
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            DbPreTestDataWorker.DeleteAllProducts();
            DbPreTestDataWorker.DeleteAllEntityCollections();

            _productService          = DbPreTestDataWorker.ProductService;
            _entityCollectionService = DbPreTestDataWorker.EntityCollectionService;

            _product = DbPreTestDataWorker.MakeExistingProduct();
            _product.ProductOptions.Add(new ProductOption("Color"));
            _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Black", "Blk"));
            _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blu"));
            _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Red", "Red"));
            _product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Green", "Gre"));
            _product.ProductOptions.Add(new ProductOption("Size"));
            _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "Sm"));
            _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "M"));
            _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "Lg"));
            _product.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("X-Large", "XL"));
            _product.Height    = 20;
            _product.Weight    = 20;
            _product.Length    = 20;
            _product.Width     = 20;
            _product.Shippable = true;
            _productService.Save(_product);
        }
Esempio n. 2
0
 public void MakeProducts()
 {
     for (var i = 0; i < ProductCount; i++)
     {
         DbPreTestDataWorker.MakeExistingProduct(
             true,
             MockDataMakerBase.GetWeight(),
             MockDataMakerBase.GetAmount());
     }
 }
Esempio n. 3
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            _product = DbPreTestDataWorker.MakeExistingProduct(weight: 10, price: 15);
            var option = new ProductOption("Color");

            _product.ProductOptions.Add(option);
            _product.ProductOptions.Add(new ProductOption("Size"));
            MerchelloContext.Current.Services.ProductService.Save(_product);
        }
        protected IProduct CreateSavedProduct()
        {
            var p = DbPreTestDataWorker.MakeExistingProduct();

            p.ProductOptions.Add(new ProductOption("Color"));
            p.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Black", "Black"));
            p.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blue"));
            DbPreTestDataWorker.ProductService.Save(p);

            return(p);
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            this._merchello = new MerchelloHelper();

            this._productOptionService = MerchelloContext.Current.Services.ProductOptionService;

            this._productService = MerchelloContext.Current.Services.ProductService;

            this.DbPreTestDataWorker.DeleteAllProducts();
            this.DbPreTestDataWorker.DeleteAllSharedOptions();

            var option = CreateSavedOption();

            _optionKey = option.Key;


            var product1 = CreateSavedProduct();

            this._product1Key = product1.Key;


            var product2 = DbPreTestDataWorker.MakeExistingProduct();

            product2.ProductOptions.Add(new ProductOption("Size"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "sm"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "md"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "lg"));

            DbPreTestDataWorker.ProductService.Save(product2);

            _product2Key = product2.Key;

            MerchelloContext.Current.Cache.RuntimeCache.ClearAllCache();
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            DbPreTestDataWorker.DeleteAllInvoices();
            DbPreTestDataWorker.DeleteAllShipCountries();


            #region Back Office

            #region Product Entry

            _product1 = DbPreTestDataWorker.MakeExistingProduct(true, 1, 1);
            _product2 = DbPreTestDataWorker.MakeExistingProduct(true, 1, 2);
            _product3 = DbPreTestDataWorker.MakeExistingProduct(true, 1, 3);
            _product4 = DbPreTestDataWorker.MakeExistingProduct(true, 1, 4);
            _product5 = DbPreTestDataWorker.MakeExistingProduct(true, 1, 5);


            #endregion

            #region WarehouseCatalog

            var defaultWarehouse = DbPreTestDataWorker.WarehouseService.GetDefaultWarehouse();
            var defaultCatalog   = defaultWarehouse.WarehouseCatalogs.FirstOrDefault();
            if (defaultCatalog == null)
            {
                Assert.Ignore("Default WarehouseCatalog is null");
            }

            #endregion // WarehouseCatalog

            #region Settings -> Shipping

            // Add countries (US & DK) to default catalog
            #region Add Countries

            var us        = MerchelloContext.Current.Services.StoreSettingService.GetCountryByCode("US");
            var usCountry = new ShipCountry(defaultCatalog.Key, us);
            ((ServiceContext)MerchelloContext.Current.Services).ShipCountryService.Save(usCountry);

            var dk        = MerchelloContext.Current.Services.StoreSettingService.GetCountryByCode("DK");
            var dkCountry = new ShipCountry(defaultCatalog.Key, dk);
            ((ServiceContext)MerchelloContext.Current.Services).ShipCountryService.Save(dkCountry);

            #endregion // ShipCountry

            #region Add a GatewayProvider (RateTableShippingGatewayProvider)

            var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey;
            var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Current.Gateways.Shipping.GetProviderByKey(key);

            #region Add and configure 3 rate table shipmethods

            var gwshipMethod1 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, usCountry, "Ground (Vary by Price)");
            gwshipMethod1.RateTable.AddRow(0, 10, 25);
            gwshipMethod1.RateTable.AddRow(10, 15, 30);
            gwshipMethod1.RateTable.AddRow(15, 25, 35);
            gwshipMethod1.RateTable.AddRow(25, 60, 40); // total price should be 50M so we should hit this tier
            gwshipMethod1.RateTable.AddRow(25, 10000, 50);
            rateTableProvider.SaveShippingGatewayMethod(gwshipMethod1);

            var gwshipMethod2 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByWeight, usCountry, "Ground (Vary by Weight)");
            gwshipMethod2.RateTable.AddRow(0, 10, 5);
            gwshipMethod2.RateTable.AddRow(10, 15, 10); // total weight should be 10M so we should hit this tier
            gwshipMethod2.RateTable.AddRow(15, 25, 25);
            gwshipMethod2.RateTable.AddRow(25, 10000, 100);
            rateTableProvider.SaveShippingGatewayMethod(gwshipMethod2);

            var gwshipMethod3 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, dkCountry, "Ground (Vary by Price)");
            gwshipMethod3.RateTable.AddRow(0, 10, 5);
            gwshipMethod3.RateTable.AddRow(10, 15, 10);
            gwshipMethod3.RateTable.AddRow(15, 25, 25);
            gwshipMethod3.RateTable.AddRow(25, 60, 30); // total price should be 50M so we should hit this tier
            gwshipMethod3.RateTable.AddRow(25, 10000, 50);
            rateTableProvider.SaveShippingGatewayMethod(gwshipMethod3);

            #endregion // ShipMethods

            #endregion // GatewayProvider

            #endregion // Shipping

            #region Settings -> Taxation

            var taxProvider = MerchelloContext.Current.Gateways.Taxation.CreateInstance(Constants.ProviderKeys.Taxation.FixedRateTaxationProviderKey);

            taxProvider.DeleteAllTaxMethods();

            var gwTaxMethod = taxProvider.CreateTaxMethod("US", 0);

            gwTaxMethod.TaxMethod.Provinces["WA"].PercentAdjustment = 8.7M;

            taxProvider.SaveTaxMethod(gwTaxMethod);


            #endregion


            #region Settings
            //// http://issues.merchello.com/youtrack/issue/M-608
            var storeSetting = DbPreTestDataWorker.StoreSettingService.GetByKey(Core.Constants.StoreSettingKeys.GlobalShippingIsTaxableKey);
            storeSetting.Value = true.ToString();
            DbPreTestDataWorker.StoreSettingService.Save(storeSetting);

            #endregion

            #endregion  // Back Office
        }
Esempio n. 7
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            #region clean up
            _detachedContentTypeService = ((ServiceContext)MerchelloContext.Current.Services).DetachedContentTypeService;

            var existingContentTypes = _detachedContentTypeService.GetAll();
            foreach (var t in existingContentTypes)
            {
                ((ServiceContext)MerchelloContext.Current.Services).DetachedContentTypeService.Delete(t);
            }

            DbPreTestDataWorker.DeleteAllProducts();
            DbPreTestDataWorker.DeleteAllEntityCollections();
            #endregion

            var catalog = DbPreTestDataWorker.WarehouseCatalog;

            var detachedContentType =
                ((ServiceContext)MerchelloContext.Current.Services).DetachedContentTypeService
                .CreateDetachedContentTypeWithKey(EntityType.Product, new Guid(), "TEST");

            _productService          = DbPreTestDataWorker.ProductService;
            _entityCollectionService = DbPreTestDataWorker.EntityCollectionService;

            var collection1 =
                _entityCollectionService.CreateEntityCollection(
                    EntityType.Product,
                    Core.Constants.ProviderKeys.EntityCollection.StaticProductCollectionProviderKey,
                    "Collection1");

            var collection2 =
                _entityCollectionService.CreateEntityCollection(
                    EntityType.Product,
                    Core.Constants.ProviderKeys.EntityCollection.StaticProductCollectionProviderKey,
                    "Collection2");

            this._original                    = DbPreTestDataWorker.MakeExistingProduct();
            _original.Barcode                 = "barcode";
            _original.Manufacturer            = "manufacturer";
            _original.ManufacturerModelNumber = "modelnumber";
            _original.CostOfGoods             = 1M;
            _original.OnSale                  = false;
            _original.SalePrice               = 2M;
            _original.Taxable                 = true;
            _original.Shippable               = true;
            _original.Height                  = 2;
            _original.Weight                  = 2;
            _original.Width                   = 2;
            _original.Length                  = 2;
            _original.Available               = true;
            _original.Download                = false;
            _original.OutOfStockPurchase      = true;
            _original.AddToCatalogInventory(catalog);
            this._original.ProductOptions.Add(new ProductOption("Color"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Black", "Blk"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blu"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Red", "Red"));
            this._original.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Green", "Gre"));
            this._original.ProductOptions.Add(new ProductOption("Size"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "Sm"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Medium", "M"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Large", "Lg"));
            this._original.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("X-Large", "XL"));
            this._original.Height    = 20;
            this._original.Weight    = 20;
            this._original.Length    = 20;
            this._original.Width     = 20;
            this._original.Shippable = true;
            _productService.Save(this._original);

            _original.AddToCollection(collection1);
            _original.AddToCollection(collection2);

            this._original.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    this._original.ProductVariantKey,
                    detachedContentType,
                    "en-US",
                    new DetachedDataValuesCollection(
                        new[]
            {
                new KeyValuePair <string, string>(
                    "description",
                    "\"<p><span>Made with real avocados, this Avocado Moisturizing Bar is great for dry skin. Layers of color are achieved by using oxide colorants. Scented with Wasabi Fragrance Oil, this soap smells slightly spicy, making it a great choice for both men and women. To ensure this soap does not overheat, place in the freezer to keep cool and prevent gel phase.</span></p>\""),
                new KeyValuePair <string, string>(
                    "brief",
                    "\"Avocado Moisturizing Bar is great for dry skin.\""),
                new KeyValuePair <string, string>(
                    "image",
                    "{ \"focalPoint\": { \"left\": 0.5, \"top\": 0.5 }, \"src\": \"/media/1035/avocadobars.jpg\" }"),
            }))
            {
                CanBeRendered = true
            });

            this._original.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    this._original.ProductVariantKey,
                    detachedContentType,
                    "en-GB",
                    new DetachedDataValuesCollection(
                        new[]
            {
                new KeyValuePair <string, string>(
                    "description",
                    "\"<p><span>Made with real avocados, this Avocado Moisturizing Bar is great for dry skin. Layers of color are achieved by using oxide colorants. Scented with Wasabi Fragrance Oil, this soap smells slightly spicy, making it a great choice for both men and women. To ensure this soap does not overheat, place in the freezer to keep cool and prevent gel phase.</span></p>\""),
                new KeyValuePair <string, string>(
                    "brief",
                    "\"Avocado Moisturizing Bar is great for dry skin.\""),
                new KeyValuePair <string, string>(
                    "image",
                    "{ \"focalPoint\": { \"left\": 0.5, \"top\": 0.5 }, \"src\": \"/media/1035/avocadobars.jpg\" }"),
            }))
            {
                CanBeRendered = true
            });

            var firstVariant = _original.ProductVariants.First();

            firstVariant.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    firstVariant.Key,
                    detachedContentType,
                    "en-US",
                    new DetachedDataValuesCollection(
                        new[]
            {
                new KeyValuePair <string, string>(
                    "description",
                    "\"<p><span>US ENGLISH VARIANT Made with real avocados, this Avocado Moisturizing Bar is great for dry skin. Layers of color are achieved by using oxide colorants. Scented with Wasabi Fragrance Oil, this soap smells slightly spicy, making it a great choice for both men and women. To ensure this soap does not overheat, place in the freezer to keep cool and prevent gel phase.</span></p>\""),
                new KeyValuePair <string, string>(
                    "brief",
                    "\"Avocado Moisturizing Bar is great for dry skin.\""),
                new KeyValuePair <string, string>(
                    "image",
                    "{ \"focalPoint\": { \"left\": 0.5, \"top\": 0.5 }, \"src\": \"/media/1035/avocadobars.jpg\" }"),
            }))
            {
                CanBeRendered = true
            });

            firstVariant.DetachedContents.Add(
                new ProductVariantDetachedContent(
                    firstVariant.Key,
                    detachedContentType,
                    "en-GB",
                    new DetachedDataValuesCollection(
                        new[]
            {
                new KeyValuePair <string, string>(
                    "description",
                    "\"<p><span>GB ENGLISH VARIANT Made with real avocados, this Avocado Moisturizing Bar is great for dry skin. Layers of color are achieved by using oxide colorants. Scented with Wasabi Fragrance Oil, this soap smells slightly spicy, making it a great choice for both men and women. To ensure this soap does not overheat, place in the freezer to keep cool and prevent gel phase.</span></p>\""),
                new KeyValuePair <string, string>(
                    "brief",
                    "\"Avocado Moisturizing Bar is great for dry skin.\""),
                new KeyValuePair <string, string>(
                    "image",
                    "{ \"focalPoint\": { \"left\": 0.5, \"top\": 0.5 }, \"src\": \"/media/1035/avocadobars.jpg\" }"),
            }))
            {
                CanBeRendered = true
            });

            _productService.Save(this._original);
        }