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);
        }
Example #2
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            _productService        = MerchelloContext.Current.Services.ProductService;
            _productVariantService = MerchelloContext.Current.Services.ProductVariantService;

            DbPreTestDataWorker.DeleteAllProducts();
        }
Example #3
0
        //[Test]
        public void ReportTestsSetup()
        {
            DbPreTestDataWorker.DeleteAllAnonymousCustomers();
            DbPreTestDataWorker.DeleteAllProducts();
            DbPreTestDataWorker.DeleteAllInvoices();

            DbPreTestDataWorker.DeleteAllShipCountries();

            this.MakeProducts();

            var defaultWarehouse = DbPreTestDataWorker.WarehouseService.GetDefaultWarehouse();
            var defaultCatalog   = defaultWarehouse.WarehouseCatalogs.FirstOrDefault();

            if (defaultCatalog == null)
            {
                Assert.Ignore("Default WarehouseCatalog is null");
            }


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

            ((ServiceContext)MerchelloContext.Current.Services).ShipCountryService.Save(usCountry);


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

            var gwshipMethod2 = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByWeight, usCountry, "Ground (Vary by Weight)");

            gwshipMethod2.RateTable.AddRow(0, 5, 5);
            gwshipMethod2.RateTable.AddRow(5, 7, 10);
            gwshipMethod2.RateTable.AddRow(7, 25, 25);
            gwshipMethod2.RateTable.AddRow(25, 10000, 100);
            rateTableProvider.SaveShippingGatewayMethod(gwshipMethod2);


            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);



            BuildOrders();
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();


            var defaultWarehouse = DbPreTestDataWorker.WarehouseService.GetDefaultWarehouse();
            var defaultCatalog   = defaultWarehouse.WarehouseCatalogs.FirstOrDefault();

            if (defaultCatalog == null)
            {
                Assert.Ignore("Default WarehouseCatalog is null");
            }

            DbPreTestDataWorker.DeleteAllShipCountries();
            var uk        = MerchelloContext.Current.Services.StoreSettingService.GetCountryByCode("GB");
            var ukCountry = new ShipCountry(defaultCatalog.Key, uk);

            ((ServiceContext)MerchelloContext.Current.Services).ShipCountryService.Save(ukCountry);

            this._settingService = MerchelloContext.Current.Services.StoreSettingService;
            var setting = this._settingService.GetByKey(Core.Constants.StoreSetting.GlobalTaxationApplicationKey);

            setting.Value = "Product";
            this._settingService.Save(setting);

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

            taxProvider.DeleteAllTaxMethods();
            var gwTaxMethod = taxProvider.CreateTaxMethod("GB", 25);

            gwTaxMethod.TaxMethod.ProductTaxMethod = true;
            taxProvider.SaveTaxMethod(gwTaxMethod);
            ((TaxationContext)MerchelloContext.Current.Gateways.Taxation).ClearProductPricingMethod();

            DbPreTestDataWorker.DeleteAllProducts();
            var product = MockProductDataMaker.MockProductForInserting("Product", "PR", 16M);

            product.SalePrice = 12M;
            MerchelloContext.Current.Services.ProductService.Save(product);
            _productKey = product.Key;
        }
Example #5
0
 public void Init()
 {
     DbPreTestDataWorker.DeleteAllProducts();
 }
Example #6
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();
            DbPreTestDataWorker.DeleteAllProducts();

            var defaultWarehouse = DbPreTestDataWorker.WarehouseService.GetDefaultWarehouse();

            _merchello = new MerchelloHelper(MerchelloContext.Current.Services, false);

            var productService          = MerchelloContext.Current.Services.ProductService;
            var entityCollectionService = MerchelloContext.Current.Services.EntityCollectionService;

            _collection = entityCollectionService.CreateEntityCollectionWithKey(
                EntityType.Product,
                Constants.ProviderKeys.EntityCollection.StaticProductCollectionProviderKey,
                "Test Merchello Helper Collection");

            var product = MockProductDataMaker.MockProductCollectionForInserting(1).First();

            product.ProductOptions.Add(new ProductOption("Color"));
            product.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blue"));
            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", "Green"));
            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", "Med"));
            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       = 11M;
            product.Price        = 30M;
            product.Width        = 11M;
            product.Length       = 11M;
            product.Barcode      = "barcode1";
            product.Manufacturer = "Manufacturer1";
            product.CostOfGoods  = 15M;
            product.OnSale       = true;
            product.SalePrice    = 25M;
            productService.Save(product);

            product.AddToCollection(_collection);

            var product2 = MockProductDataMaker.MockProductCollectionForInserting(1).First();

            product2.ProductOptions.Add(new ProductOption("Color"));
            product2.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Purple", "purple"));
            product2.ProductOptions.Add(new ProductOption("Size"));
            product2.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "Sm"));
            product2.Price        = 40M;
            product2.Height       = 11M;
            product2.Width        = 11M;
            product2.Length       = 11M;
            product2.CostOfGoods  = 15M;
            product2.Barcode      = "barcode2";
            product2.Manufacturer = "Manufacturer2";
            product2.OnSale       = false;
            product2.SalePrice    = 35M;
            product2.AddToCatalogInventory(defaultWarehouse.DefaultCatalog());
            productService.Save(product2);
            product2.CatalogInventories.First().Count = 10;
            productService.Save(product2);

            product2.AddToCollection(_collection);

            var product3 = MockProductDataMaker.MockProductCollectionForInserting(1).First();

            product3.ProductOptions.Add(new ProductOption("Color"));
            product3.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Blue", "Blue"));
            product3.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Red", "Red"));
            product3.ProductOptions.First(x => x.Name == "Color").Choices.Add(new ProductAttribute("Green", "Green"));
            product3.Price        = 20M;
            product3.Height       = 11M;
            product3.Width        = 11M;
            product3.Length       = 11M;
            product3.CostOfGoods  = 15M;
            product3.Barcode      = "barcode3";
            product3.Manufacturer = "Manufacturer2";
            product3.OnSale       = false;
            product3.SalePrice    = 20M;
            product3.AddToCatalogInventory(defaultWarehouse.DefaultCatalog());
            productService.Save(product3);
            product3.CatalogInventories.First().Count = 10;
            productService.Save(product3);


            var product4 = MockProductDataMaker.MockProductCollectionForInserting(1).First();

            product4.ProductOptions.Add(new ProductOption("Size"));
            product4.ProductOptions.First(x => x.Name == "Size").Choices.Add(new ProductAttribute("Small", "Sm"));
            product4.ProductOptions.Add(new ProductOption("Material"));
            product4.ProductOptions.First(x => x.Name == "Material").Choices.Add(new ProductAttribute("Wood", "wood"));
            product4.ProductOptions.First(x => x.Name == "Material").Choices.Add(new ProductAttribute("Plastic", "plastic"));
            product4.Price        = 21M;
            product4.Height       = 11M;
            product4.Width        = 11M;
            product4.Length       = 11M;
            product4.CostOfGoods  = 15M;
            product4.Barcode      = "barcode4";
            product4.Manufacturer = "Manufacturer3";
            product4.OnSale       = true;
            product4.SalePrice    = 18M;
            product4.AddToCatalogInventory(defaultWarehouse.DefaultCatalog());
            productService.Save(product4);
            product4.CatalogInventories.First().Count = 10;
            productService.Save(product4);

            product4.AddToCollection(_collection);
        }
 public void Setup()
 {
     DbPreTestDataWorker.DeleteAllEntityCollections();
     DbPreTestDataWorker.DeleteAllProducts();
 }
Example #8
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);
        }