Example #1
0
        /// <summary>
        /// delete bundles from a product bundle and check if the deletion was successful
        /// </summary>
        public void testDelete()
        {
            Console.WriteLine("ProductBundleTest: testDelete");

            TBundledProductPath bundledProductPath = new TBundledProductPath();

            bundledProductPath.Path = bundled_product2;
            TBundledProductPath[] bundledProductPaths = new TBundledProductPath[] { bundledProductPath };

            TDelete_Input productBundle = new TDelete_Input();

            productBundle.Product             = product;
            productBundle.BundledProductPaths = bundledProductPaths;

            TDelete_Input[]  productBundles     = new TDelete_Input[] { productBundle };
            TDelete_Return[] productBundles_out = productBundleService.delete(productBundles);

            // test if deletion was successful
            Assert.AreEqual(1, productBundles_out.GetLength(0), "delete result count");
            TDelete_Return productBundle_out = productBundles_out[0];

            Assert.IsNull(productBundle_out.Error, "delete: no error");
            Assert.AreEqual(product, productBundle_out.Product, "Product path");
            Assert.IsTrue(productBundle_out.deleted, "deleted?");
        }
        /// <summary>
        /// delete a cross selling and check if the deletion was successful
        /// </summary>
        public void testDelete()
        {
            Console.WriteLine("CrossSellingTest: testDelete");

            TDelete_Input crossSelling = new TDelete_Input();

            crossSelling.Product       = product;
            crossSelling.TargetProduct = target_product;
            crossSelling.Type          = "CrossSelling";

            TDelete_Input productComparison = new TDelete_Input();

            productComparison.Product       = product;
            productComparison.TargetProduct = target_product;
            productComparison.Type          = "ProductComparison";

            TDelete_Input accessory = new TDelete_Input();

            accessory.Product       = product;
            accessory.TargetProduct = target_product;
            accessory.Type          = "Accessory";

            TDelete_Input[] CrossSellings = new TDelete_Input[] {
                crossSelling,
                productComparison,
                accessory,
            };

            TDelete_Return[] CrossSellings_out = crossSellingService.delete(CrossSellings);

            // test if deletion was successful
            Assert.AreEqual(3, CrossSellings_out.GetLength(0), "delete result count");

            TDelete_Return CrossSelling_out = CrossSellings_out[0];

            Assert.IsNull(CrossSelling_out.Error, "delete: no error");
            Assert.AreEqual(product, CrossSelling_out.Product, "Product path");
            Assert.IsTrue(CrossSelling_out.deleted, "deleted?");
        }
        public void Init()
        {
            Console.WriteLine("CrossSellingTest: Init");

            TLocalizedValue comment1_de = new TLocalizedValue();

            comment1_de.LanguageCode = "de";
            comment1_de.Value        = ".net CrossSellingService Test";
            TLocalizedValue comment1_en = new TLocalizedValue();

            comment1_en.LanguageCode = "en";
            comment1_en.Value        = ".net CrossSellingService Test";
            Comment1 = new TLocalizedValue[] { comment1_de, comment1_en };

            TLocalizedValue comment2_de = new TLocalizedValue();

            comment2_de.LanguageCode = "de";
            comment2_de.Value        = ".net CrossSellingService Test Aktualisierung";
            TLocalizedValue comment2_en = new TLocalizedValue();

            comment2_en.LanguageCode = "en";
            comment2_en.Value        = ".net CrossSellingService test update";
            Comment2 = new TLocalizedValue[] { comment2_de, comment2_en };

            crossSellingService                 = new CrossSellingService();
            crossSellingService.Credentials     = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD);
            crossSellingService.PreAuthenticate = true;
            crossSellingService.Url             = WEBSERVICE_URL;

            // remove all assigned cross selling products
            TDelete_Input CrossSelling_in = new TDelete_Input();

            CrossSelling_in.Product       = product;
            CrossSelling_in.TargetProduct = "*";
            CrossSelling_in.Type          = "CrossSelling";
            TDelete_Input[]  CrossSellings     = new TDelete_Input[] { CrossSelling_in };
            TDelete_Return[] CrossSellings_out = crossSellingService.delete(CrossSellings);

            Console.WriteLine("delete all CrossSelling: " + CrossSellings_out.GetLength(0));
            foreach (TDelete_Return result in CrossSellings_out)
            {
                if (result.Error != null)
                {
                    Console.Error.WriteLine("delete CrossSelling failed:" + result.Error.Message);
                }
                else
                {
                    Console.WriteLine("deleted CrossSelling: " + result.TargetProduct + " : " + result.deleted);
                }
            }

            CrossSelling_in               = new TDelete_Input();
            CrossSelling_in.Product       = product;
            CrossSelling_in.TargetProduct = "*";
            CrossSelling_in.Type          = "Accessory";
            CrossSellings     = new TDelete_Input[] { CrossSelling_in };
            CrossSellings_out = crossSellingService.delete(CrossSellings);

            Console.WriteLine("delete all Accessory: " + CrossSellings_out.GetLength(0));
            foreach (TDelete_Return result in CrossSellings_out)
            {
                if (result.Error != null)
                {
                    Console.Error.WriteLine("delete failed:" + result.Error.Message);
                }
                else
                {
                    Console.WriteLine("deleted Accessory: " + result.TargetProduct + " : " + result.deleted);
                }
            }

            CrossSelling_in               = new TDelete_Input();
            CrossSelling_in.Product       = product;
            CrossSelling_in.TargetProduct = "*";
            CrossSelling_in.Type          = "ProductComparison";
            CrossSellings     = new TDelete_Input[] { CrossSelling_in };
            CrossSellings_out = crossSellingService.delete(CrossSellings);

            Console.WriteLine("delete all ProductComparison: " + CrossSellings_out.GetLength(0));
            foreach (TDelete_Return result in CrossSellings_out)
            {
                if (result.Error != null)
                {
                    Console.Error.WriteLine("delete ProductComparison failed:" + result.Error.Message);
                }
                else
                {
                    Console.WriteLine("deleted ProductComparison: " + result.TargetProduct + " : " + result.deleted);
                }
            }
        }