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 Init()
        {
            var worker = new DbPreTestDataWorker();

            _database = worker.Database;
            _creation = new BaseDataCreation(_database);
        }
        public virtual void FixtureSetup()
        {
            var serviceContext = new ServiceContext(new PetaPocoUnitOfWorkProvider());

            _dbPreTestDataWorker = new DbPreTestDataWorker(serviceContext);

            if (!GatewayProviderResolver.HasCurrent)
            GatewayProviderResolver.Current = new GatewayProviderResolver(
            PluginManager.Current.ResolveGatewayProviders(),
            serviceContext.GatewayProviderService,
            new NullCacheProvider());

            MerchelloContext = new MerchelloContext(serviceContext,
                new GatewayContext(serviceContext, GatewayProviderResolver.Current),
                new CacheHelper(new NullCacheProvider(),
                                    new NullCacheProvider(),
                                    new NullCacheProvider()));

            if (!TriggerResolver.HasCurrent)
                TriggerResolver.Current = new TriggerResolver(PluginManager.Current.ResolveObservableTriggers());

            if (!MonitorResolver.HasCurrent)
                MonitorResolver.Current = new MonitorResolver(MerchelloContext.Gateways.Notification, PluginManager.Current.ResolveObserverMonitors());

            AutoMapperMappings.CreateMappings();
            ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"].RebuildIndex();
            ExamineManager.Instance.IndexProviderCollection["MerchelloCustomerIndexer"].RebuildIndex();
        }
Esempio n. 4
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

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

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

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

            _else = DbPreTestDataWorker.ShipCountryService.GetShipCountryByCountryCode(defaultCatalog.Key, "ELSE");

            var key = Constants.ProviderKeys.Shipping.FixedRateShippingProviderKey;
            var rateTableProvider = (FixedRateShippingGatewayProvider)MerchelloContext.Current.Gateways.Shipping.GetProviderByKey(key);
            var gwshipMethod1     = (FixedRateShippingGatewayMethod)rateTableProvider.CreateShipMethod(FixedRateShippingGatewayMethod.QuoteType.VaryByPrice, _else, "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);
        }
Esempio n. 5
0
        public void Init()
        {
            if (!_provider.Activated)
            {
                MerchelloContext.Current.Gateways.Notification.ActivateProvider(_provider);
            }

            DbPreTestDataWorker.DeleteAllNotificationMethods();

            //// Arrange
            var resource = _provider.ListResourcesOffered().FirstOrDefault();

            Assert.NotNull(resource, "Smtp Provider returned null for GatewayResource");
            var method = _provider.CreateNotificationMethod(resource, resource.Name, "SMTP Relayed Email");

            _provider.SaveNotificationMethod(method);
            Assert.NotNull(method, "method was null");

            //// Act
            _message = new NotificationMessage(method.NotificationMethod.Key, "Test email",
                                               "*****@*****.**")
            {
                Recipients     = "*****@*****.**",
                BodyText       = "Successful test?",
                MonitorKey     = _monitorKey,
                SendToCustomer = true
            };

            method.SaveNotificationMessage(_message);



            //// Assert
            Assert.IsTrue(_message.HasIdentity);
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            DbPreTestDataWorker.DeleteAllEntityCollections();

            _service = MerchelloContext.Current.Services.EntityCollectionService;

            this._query = ProxyQueryManager.Current.Instance <ProductCollectionTreeQuery>();

            var providerKey = Constants.ProviderKeys.EntityCollection.StaticProductCollectionProviderKey;

            root1 = _service.CreateEntityCollectionWithKey(EntityType.Product, providerKey, "root1", false);

            root2 = _service.CreateEntityCollectionWithKey(EntityType.Product, providerKey, "root2", false);

            a           = _service.CreateEntityCollection(EntityType.Product, providerKey, "a", false);
            a.ParentKey = root1.Key;

            b           = _service.CreateEntityCollection(EntityType.Product, providerKey, "b", false);
            b.ParentKey = root1.Key;

            c           = _service.CreateEntityCollection(EntityType.Product, providerKey, "c", false);
            c.ParentKey = root1.Key;

            _service.Save(new [] { a, b, c });

            a1           = _service.CreateEntityCollection(EntityType.Product, providerKey, "a1", false);
            a1.ParentKey = a.Key;

            a2           = _service.CreateEntityCollection(EntityType.Product, providerKey, "a2", false);
            a2.ParentKey = a.Key;

            _service.Save(new[] { a1, a2 });

            a1a           = _service.CreateEntityCollection(EntityType.Product, providerKey, "a1a", false);
            a1a.ParentKey = a1.Key;


            a1b           = _service.CreateEntityCollection(EntityType.Product, providerKey, "a1b", false);
            a1b.ParentKey = a1.Key;

            _service.Save(new[] { a1a, a1b });


            c1           = _service.CreateEntityCollection(EntityType.Product, providerKey, "c1", false);
            c1.ParentKey = c.Key;

            c2           = _service.CreateEntityCollection(EntityType.Product, providerKey, "c2", false);
            c2.ParentKey = c.Key;

            _service.Save(new[] { c1, c2 });

            c2a           = _service.CreateEntityCollection(EntityType.Product, providerKey, "c2a", false);
            c2a.ParentKey = c2.Key;

            _service.Save(c2a);

            _merchello = new MerchelloHelper();
        }
Esempio n. 7
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            DbPreTestDataWorker.DeleteAllInvoices();
            DbPreTestDataWorker.DeleteAllShipCountries();
        }
Esempio n. 8
0
        //[Test]
        public void Can_Upgrade_VersionOneZeroOne_ToVersionOneoneZero_A_Database()
        {
            var worker   = new DbPreTestDataWorker();
            var database = worker.Database;

            var migrationHelper = new MigrationHelper(database);

            migrationHelper.UpgradeTargetVersionOneOneZero();
        }
Esempio n. 9
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();
            DbPreTestDataWorker.DeleteAllInvoices();

            DbPreTestDataWorker.MakeExistingInvoices(15);

            _db = DbPreTestDataWorker.Database;
        }
Esempio n. 10
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

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

            DbPreTestDataWorker.DeleteAllProducts();
        }
Esempio n. 11
0
        public void Init()
        {
            var syntax = (DbSyntax)Enum.Parse(typeof(DbSyntax), ConfigurationManager.AppSettings["syntax"]);
            var worker = new DbPreTestDataWorker {
                SqlSyntax = syntax
            };

            _database = worker.Database;
        }
Esempio n. 12
0
        //[Test]
        public void Can_Upgrade_VersionOneZeroOne_ToVersionOneoneZero_A_Database()
        {
            var worker = new DbPreTestDataWorker();
            var database = worker.Database;

            var migrationHelper = new MigrationHelper(database);

            migrationHelper.UpgradeTargetVersionOneOneZero();
        }
Esempio n. 13
0
        public void Can_Get_ExpressCheckoutResponse()
        {
            //// Arrange
            var invoice = DbPreTestDataWorker.MakeExistingInvoices().First();


            //// Act

            //// Assert
        }
Esempio n. 14
0
 public void MakeProducts()
 {
     for (var i = 0; i < ProductCount; i++)
     {
         DbPreTestDataWorker.MakeExistingProduct(
             true,
             MockDataMakerBase.GetWeight(),
             MockDataMakerBase.GetAmount());
     }
 }
        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);
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        public void Init()
        {
            var syntax = (DbSyntax)Enum.Parse(typeof(DbSyntax), ConfigurationManager.AppSettings["syntax"]);
            var worker = new DbPreTestDataWorker {
                SqlSyntax = syntax
            };

            _database = worker.Database;
            var deletions = new DatabaseSchemaCreation(_database);

            deletions.UninstallDatabaseSchema();
        }
Esempio n. 18
0
        public void Init()
        {
            var syntax = (DbSyntax)Enum.Parse(typeof(DbSyntax), ConfigurationManager.AppSettings["syntax"]);
            var worker = new DbPreTestDataWorker {
                SqlSyntax = syntax
            };
            var logger    = Logger.CreateWithDefaultLog4NetConfiguration();
            var sqlSyntax = SqlSyntaxProviderTestHelper.SqlSyntaxProvider(syntax);

            _database             = worker.Database;
            _databaseSchemaHelper = new MerchelloDatabaseSchemaHelper(_database, logger, sqlSyntax);
        }
Esempio n. 19
0
        public void Can_Add_Customers_To_Collections()
        {
            //// Arrange
            var customer1 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());
            var customer2 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());
            var customer3 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());
            var customer4 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());


            var collection1 = _entityCollectionService.CreateEntityCollectionWithKey(
                EntityType.Customer,
                _providerKey,
                "Customer Collection1");

            var provider1 = collection1.ResolveProvider <StaticCustomerCollectionProvider>();

            Assert.NotNull(provider1);
            Assert.AreEqual(typeof(StaticCustomerCollectionProvider), provider1.GetType());

            var collection2 = _entityCollectionService.CreateEntityCollectionWithKey(
                EntityType.Customer,
                _providerKey,
                "Customer Collection2");

            var provider2 = collection2.ResolveProvider <StaticCustomerCollectionProvider>();

            Assert.NotNull(provider2);
            Assert.AreEqual(typeof(StaticCustomerCollectionProvider), provider2.GetType());


            //// Act
            customer1.AddToCollection(collection1);
            customer2.AddToCollection(collection1);
            customer3.AddToCollection(collection1);
            customer4.AddToCollection(collection1);
            customer3.AddToCollection(collection2);
            customer4.AddToCollection(collection2);

            //// Assert
            var c1Customers = collection1.GetEntities <ICustomer>().ToArray();
            var c2Customers = collection2.GetEntities <ICustomer>().ToArray();

            Assert.IsTrue(c1Customers.Any());
            Assert.IsTrue(c2Customers.Any());

            Assert.AreEqual(4, c1Customers.Count());
            Assert.AreEqual(2, c2Customers.Count());

            var c1 = c1Customers.First();

            Assert.IsTrue(c1.GetCollectionsContaining().Any());
        }
Esempio n. 20
0
        public void Init()
        {
            var syntax = (DbSyntax)Enum.Parse(typeof(DbSyntax), ConfigurationManager.AppSettings["syntax"]);

            _worker = new DbPreTestDataWorker {
                SqlSyntax = syntax
            };

            var schemaHelper = new DatabaseSchemaHelper(_worker.Database, _worker.TestLogger, _worker.SqlSyntaxProvider);
            var deletions    = new DatabaseSchemaCreation(_worker.Database, _worker.TestLogger, schemaHelper, _worker.SqlSyntaxProvider);

            deletions.UninstallDatabaseSchema();
        }
        public virtual void FixtureSetup()
        {
            var syntax = (DbSyntax)Enum.Parse(typeof(DbSyntax), ConfigurationManager.AppSettings["syntax"]);

            // sets up the Umbraco SqlSyntaxProvider Singleton OBSOLETE
            SqlSyntaxProviderTestHelper.EstablishSqlSyntax(syntax);

            var sqlSyntax = SqlSyntaxProviderTestHelper.SqlSyntaxProvider(syntax);

            //AutoMapperMappings.CreateMappings();
            var logger = Logger.CreateWithDefaultLog4NetConfiguration();

            var cache = new CacheHelper(
                new ObjectCacheRuntimeCacheProvider(),
                new StaticCacheProvider(),
                new NullCacheProvider());

            var serviceContext = new ServiceContext(new RepositoryFactory(cache, logger, sqlSyntax), new PetaPocoUnitOfWorkProvider(logger), logger, new TransientMessageFactory());

            _dbPreTestDataWorker = new DbPreTestDataWorker(serviceContext);

            // Umbraco Application
            var applicationMock = new Mock<UmbracoApplication>();

            // Merchello CoreBootStrap
            var bootManager = new Web.WebBootManager(logger, _dbPreTestDataWorker.SqlSyntaxProvider);
            bootManager.Initialize();

            if (MerchelloContext.Current == null) Assert.Ignore("MerchelloContext.Current is null");

            //if (!GatewayProviderResolver.HasCurrent)
            //    GatewayProviderResolver.Current = new GatewayProviderResolver(
            //    PluginManager.Current.ResolveGatewayProviders(),
            //    serviceContext.GatewayProviderService,
            //    new NullCacheProvider());

            //MerchelloContext = new MerchelloContext(serviceContext,
            //    new GatewayContext(serviceContext, GatewayProviderResolver.Current),
            //    new CacheHelper(new NullCacheProvider(),
            //                        new NullCacheProvider(),
            //                        new NullCacheProvider()));

            //if (!TriggerResolver.HasCurrent)
            //    TriggerResolver.Current = new TriggerResolver(PluginManager.Current.ResolveObservableTriggers());

            //if (!MonitorResolver.HasCurrent)
            //    MonitorResolver.Current = new MonitorResolver(MerchelloContext.Gateways.Notification, PluginManager.Current.ResolveObserverMonitors());

            ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"].RebuildIndex();
            ExamineManager.Instance.IndexProviderCollection["MerchelloCustomerIndexer"].RebuildIndex();
        }
Esempio n. 22
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();
        }
Esempio n. 23
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            AutoMapper.Mapper.CreateMap <IValidatableAddress, TaxAddress>();

            AvaTaxService = new AvaTaxService(TestHelper.GetAvaTaxProviderSettings());

            SqlSyntaxProviderTestHelper.EstablishSqlSyntax();

            DataWorker = new DbPreTestDataWorker(new ServiceContext(new PetaPocoUnitOfWorkProvider()));

            MakeInvoice();
        }
Esempio n. 24
0
        public void Can_Remove_Customers_From_A_Collection()
        {
            //// Arrange
            var customer1 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());
            var customer2 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());
            var customer3 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());
            var customer4 = DbPreTestDataWorker.MakeExistingCustomer(Guid.NewGuid().ToString());


            var collection1 = _entityCollectionService.CreateEntityCollectionWithKey(
                EntityType.Customer,
                _providerKey,
                "Customer Collection1");


            customer1.AddToCollection(collection1);
            customer2.AddToCollection(collection1);
            customer3.AddToCollection(collection1);
            customer4.AddToCollection(collection1);
            var provider = collection1.ResolveProvider <StaticCustomerCollectionProvider>();

            Assert.NotNull(provider);

            //// Act

            var ccustomers = collection1.GetEntities <ICustomer>().ToArray();

            Assert.AreEqual(4, ccustomers.Count());

            var remove = ccustomers.First();
            var key    = remove.Key;

            remove.RemoveFromCollection(collection1);

            //// Assert
            var afterRemove = collection1.GetEntities <ICustomer>().ToArray();

            Assert.AreEqual(3, afterRemove.Count());
            Assert.False(afterRemove.Any(x => x.Key == key));
            Assert.IsFalse(collection1.Exists(remove));
            Assert.IsFalse(remove.GetCollectionsContaining().Any());
        }
        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;
        }
        public virtual void FixtureSetup()
        {
            //AutoMapperMappings.CreateMappings();
            var logger = Logger.CreateWithDefaultLog4NetConfiguration();
            var serviceContext = new ServiceContext(new RepositoryFactory(), new PetaPocoUnitOfWorkProvider(logger), logger, new TransientMessageFactory());

            _dbPreTestDataWorker = new DbPreTestDataWorker(serviceContext);

            // Umbraco Application
            var applicationMock = new Mock<UmbracoApplication>();

            // Merchello CoreBootStrap
            var bootManager = new Web.WebBootManager(logger);
            bootManager.Initialize();

            if (MerchelloContext.Current == null) Assert.Ignore("MerchelloContext.Current is null");

            //if (!GatewayProviderResolver.HasCurrent)
            //    GatewayProviderResolver.Current = new GatewayProviderResolver(
            //    PluginManager.Current.ResolveGatewayProviders(),
            //    serviceContext.GatewayProviderService,
            //    new NullCacheProvider());

            //MerchelloContext = new MerchelloContext(serviceContext,
            //    new GatewayContext(serviceContext, GatewayProviderResolver.Current),
            //    new CacheHelper(new NullCacheProvider(),
            //                        new NullCacheProvider(),
            //                        new NullCacheProvider()));

            //if (!TriggerResolver.HasCurrent)
            //    TriggerResolver.Current = new TriggerResolver(PluginManager.Current.ResolveObservableTriggers());

            //if (!MonitorResolver.HasCurrent)
            //    MonitorResolver.Current = new MonitorResolver(MerchelloContext.Gateways.Notification, PluginManager.Current.ResolveObserverMonitors());

            ExamineManager.Instance.IndexProviderCollection["MerchelloProductIndexer"].RebuildIndex();
            ExamineManager.Instance.IndexProviderCollection["MerchelloCustomerIndexer"].RebuildIndex();
        }
        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();
        }
Esempio n. 28
0
 public void Setup()
 {
     DbPreTestDataWorker.DeleteAllEntityCollections();
     DbPreTestDataWorker.DeleteAllCustomers();
 }
Esempio n. 29
0
 public void Init()
 {
     DbPreTestDataWorker.DeleteAllProducts();
 }
Esempio n. 30
0
 public void init()
 {
     DbPreTestDataWorker.DeleteAllAnonymousCustomers();
     DbPreTestDataWorker.DeleteAllInvoices();
 }
Esempio n. 31
0
 public void clean()
 {
     DbPreTestDataWorker.DeleteAllOrders();
 }
        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. 33
0
        public void BuildOrders()
        {
            var products  = DbPreTestDataWorker.ProductService.GetAll().ToArray();
            var addresses = MockDataMakerBase.FakeAddresses().Where(x => x.CountryCode == "US").ToArray();

            var maxProductIndex = products.Count() - 1;
            var maxAddressIndex = addresses.Count();

            var itemCount = MockDataMakerBase.NoWhammyStop.Next(11);

            var invoiceDate = DateTime.Today.AddDays(-1 * InvoiceCount);

            for (var j = 0; j < InvoiceCount; j++)
            {
                if (j % 2 == 0)
                {
                    CurrentCustomer = DbPreTestDataWorker.MakeExistingAnonymousCustomer();
                }

                for (var i = 0; i < itemCount; i++)
                {
                    CurrentCustomer.Basket().AddItem(products[MockDataMakerBase.NoWhammyStop.Next(maxProductIndex)], MockDataMakerBase.NoWhammyStop.Next(5));
                }
                CurrentCustomer.Basket().Save();



                // Customer enters the destination shipping address
                var destination = addresses[MockDataMakerBase.NoWhammyStop.Next(maxAddressIndex)];

                // Assume customer selects billing address is same as shipping address
                CurrentCustomer.Basket().SalePreparation().SaveBillToAddress(destination);

                // --------------- ShipMethod Selection ----------------------------------

                // Package the shipments
                //
                // This should return a collection containing a single shipment
                //
                var shipments = CurrentCustomer.Basket().PackageBasket(destination).ToArray();

                var shipment = shipments.FirstOrDefault();

                if (shipment != null)
                {
                    var shipRateQuotes = shipment.ShipmentRateQuotes().ToArray();

                    CurrentCustomer.Basket().SalePreparation().SaveShipmentRateQuote(shipRateQuotes.First());
                }

                var paymentMethods = CurrentCustomer.Basket().SalePreparation().GetPaymentGatewayMethods();


                IPaymentResult paymentResult;
                paymentResult = invoiceDate.Month < DateTime.Now.AddDays(-30).Month
                    ?
                                CurrentCustomer.Basket()
                                .SalePreparation()
                                .AuthorizeCapturePayment(paymentMethods.FirstOrDefault())
                    :
                                CurrentCustomer.Basket()
                                .SalePreparation()
                                .AuthorizePayment(paymentMethods.FirstOrDefault());

                var invoice = paymentResult.Invoice;

                invoice.InvoiceDate = invoiceDate;

                invoiceDate = invoiceDate.AddDays(1);

                DbPreTestDataWorker.InvoiceService.Save(invoice);
            }
        }
Esempio n. 34
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);
        }