/// <summary> /// test create /// </summary> public void testCreate() { Console.WriteLine("ProductTypeTest: testCreate start"); TCreate_Input create1 = new TCreate_Input(); create1.Alias = NET_TEST1_ALIAS; create1.LayoutContentBundles = NET_TEST1_LAYOUT_BUNDLES; TLocalizedValue name1_de = new TLocalizedValue(); name1_de.LanguageCode = "de"; name1_de.Value = NET_TEST1_NAME_DE; TLocalizedValue name1_en = new TLocalizedValue(); name1_en.LanguageCode = "en"; name1_en.Value = NET_TEST1_NAME_EN; create1.Name = new TLocalizedValue[] { name1_de, name1_en }; TCreate_Input create2 = new TCreate_Input(); create2.Alias = NET_TEST2_ALIAS; create2.LayoutContentBase = NET_TEST2_LAYOUT_BASE; TLocalizedValue name2_de = new TLocalizedValue(); name2_de.LanguageCode = "de"; name2_de.Value = NET_TEST2_NAME_DE; TLocalizedValue name2_en = new TLocalizedValue(); name2_en.LanguageCode = "en"; name2_en.Value = NET_TEST2_NAME_EN; create2.Name = new TLocalizedValue[] { name2_de, name2_en }; TCreate_Input[] createProductTypes = new TCreate_Input[] { create1, create2 }; TCreate_Return[] productTypes = productTypeService.create(createProductTypes); Assert.AreEqual(createProductTypes.Length, productTypes.Length); Assert.AreEqual(NET_TEST1_ALIAS, productTypes[0].Alias); Assert.IsNull(productTypes[0].Error); Assert.IsTrue(productTypes[0].created); Assert.AreEqual(NET_TEST1_PATH, productTypes[0].Path); Assert.AreEqual(NET_TEST2_ALIAS, productTypes[1].Alias); Assert.IsNull(productTypes[1].Error); Assert.IsTrue(productTypes[1].created); Assert.AreEqual(NET_TEST2_PATH, productTypes[1].Path); Console.WriteLine("ProductTypeTest: testCreate end"); }
/// <summary> /// test createProductAttribute /// </summary> public void testCreateProductAttribute() { Console.WriteLine("ProductTypeTest: testCreateProductAttribute start"); TCreateProductAttribute_Input in1 = new TCreateProductAttribute_Input(); in1.Alias = ATTRIBUTE1_ALIAS; in1.Type = ATTRIBUTE1_TYPE; TLocalizedValue Name1DE = new TLocalizedValue(); Name1DE.LanguageCode = "de"; Name1DE.Value = ATTRIBUTE1_NAME_DE; TLocalizedValue Name1EN = new TLocalizedValue(); Name1EN.LanguageCode = "en"; Name1EN.Value = ATTRIBUTE1_NAME_EN; in1.Name = new TLocalizedValue[] { Name1DE, Name1EN }; TLocalizedValue Descr1DE = new TLocalizedValue(); Descr1DE.LanguageCode = "de"; Descr1DE.Value = ATTRIBUTE1_DESCR_DE; TLocalizedValue Descr1EN = new TLocalizedValue(); Descr1EN.LanguageCode = "en"; Descr1EN.Value = ATTRIBUTE1_DESCR_EN; in1.Description = new TLocalizedValue[] { Descr1DE, Descr1EN }; in1.IsVisible = true; in1.IsVisibleSpecified = true; in1.IsHTML = true; in1.IsHTMLSpecified = true; in1.Position = "8192"; TCreateProductAttribute_Input in2 = new TCreateProductAttribute_Input(); in2.Alias = ATTRIBUTE2_ALIAS; in2.Type = ATTRIBUTE2_TYPE; TLocalizedValue Name2DE = new TLocalizedValue(); Name2DE.LanguageCode = "de"; Name2DE.Value = ATTRIBUTE2_NAME_DE; TLocalizedValue Name2EN = new TLocalizedValue(); Name2EN.LanguageCode = "en"; Name2EN.Value = ATTRIBUTE2_NAME_EN; in2.Name = new TLocalizedValue[] { Name2DE, Name2EN }; TLocalizedValue Descr2DE = new TLocalizedValue(); Descr2DE.LanguageCode = "de"; Descr2DE.Value = ATTRIBUTE2_DESCR_DE; TLocalizedValue Descr2EN = new TLocalizedValue(); Descr2EN.LanguageCode = "en"; Descr2EN.Value = ATTRIBUTE2_DESCR_EN; in2.Description = new TLocalizedValue[] { Descr2DE, Descr2EN }; in2.Position = "4096"; TCreateProductAttribute_Input in3 = new TCreateProductAttribute_Input(); in3.Alias = "CurrencyID"; // reserved attribute alias in3.Type = ATTRIBUTE1_TYPE; TCreateProductAttribute_Input[] input = {in1, in2, in3}; TCreateProductAttribute_Return[] attributes = productTypeService.createProductAttribute( NET_TEST1_PATH, input ); Assert.IsNotNull(attributes); Assert.AreEqual(input.Length, attributes.Length); Assert.AreEqual(ATTRIBUTE1_ALIAS, attributes[0].Alias); Assert.IsNull(attributes[0].Error); Assert.AreEqual(ATTRIBUTE1_PATH, attributes[0].Path); Assert.IsTrue(attributes[0].created); Assert.AreEqual(ATTRIBUTE2_ALIAS, attributes[1].Alias); Assert.IsNull(attributes[1].Error); Assert.AreEqual(ATTRIBUTE2_PATH, attributes[1].Path); Assert.IsTrue(attributes[1].created); Assert.AreEqual("CurrencyID", attributes[2].Alias); Assert.IsNotNull(attributes[2].Error); Console.WriteLine("ProductTypeTest: testCreateProductAttribute end"); }
/// <summary> /// test updateProductAttribute /// </summary> public void testUpdateProductAttribute() { Console.WriteLine("ProductTypeTest: testUpdateProductAttribute start"); TUpdateProductAttribute_Input in1 = new TUpdateProductAttribute_Input(); in1.Alias = ATTRIBUTE1_ALIAS; in1.IsHTML = false; in1.IsHTMLSpecified = true; in1.Position = "1"; TLocalizedValue descr1EN = new TLocalizedValue(); descr1EN.LanguageCode = "en"; descr1EN.Value = ATTRIBUTE1_DESCR_EN + "updated"; in1.Description = new TLocalizedValue[]{descr1EN}; TUpdateProductAttribute_Input in2 = new TUpdateProductAttribute_Input(); in2.Alias = ATTRIBUTE2_ALIAS; in2.IsVisible = true; in2.IsVisibleSpecified = true; TLocalizedValue name2DE = new TLocalizedValue(); name2DE.LanguageCode = "de"; name2DE.Value = ATTRIBUTE2_NAME_DE + "updated"; in2.Name = new TLocalizedValue[]{name2DE}; TUpdateProductAttribute_Input in3 = new TUpdateProductAttribute_Input(); in3.Alias = NOT_EXISTING_ALIAS; TUpdateProductAttribute_Return[] attributes = productTypeService.updateProductAttribute( NET_TEST1_PATH, new TUpdateProductAttribute_Input[]{in1, in2, in3} ); Assert.IsNotNull(attributes); Assert.AreEqual(3, attributes.Length); Assert.AreEqual(ATTRIBUTE1_ALIAS, attributes[0].Alias); Assert.IsNull(attributes[0].Error); Assert.IsTrue(attributes[0].updated); Assert.AreEqual(ATTRIBUTE2_ALIAS, attributes[1].Alias); Assert.IsNull(attributes[1].Error); Assert.IsTrue(attributes[1].updated); Assert.AreEqual(NOT_EXISTING_ALIAS, attributes[2].Alias); Assert.IsNotNull(attributes[2].Error); TGetProductAttributeInfo_Return[] attributes2 = productTypeService.getProductAttributeInfo( NET_TEST1_PATH, new String[]{ATTRIBUTE1_ALIAS, ATTRIBUTE2_ALIAS}, new String[]{"en", "de"} ); Assert.IsNotNull(attributes2); Assert.AreEqual(2, attributes2.Length); Assert.AreEqual(ATTRIBUTE1_ALIAS, attributes2[0].Alias); Assert.IsNull(attributes2[0].Error); Assert.AreEqual(ATTRIBUTE1_PATH, attributes2[0].Path); Assert.IsTrue(attributes2[0].IsVisible); Assert.IsFalse(attributes2[0].IsHTML); Assert.AreEqual(0, Int32.Parse(attributes2[0].Position) % 10); TLocalizedValue[] descriptions = attributes2[0].Description; Assert.AreEqual(2, descriptions.Length); foreach (TLocalizedValue description in descriptions) { if ("de".Equals(description.LanguageCode)) Assert.AreEqual(ATTRIBUTE1_DESCR_DE, description.Value); else if ("en".Equals(description.LanguageCode)) Assert.AreEqual(ATTRIBUTE1_DESCR_EN + "updated", description.Value); } Assert.AreEqual(ATTRIBUTE2_ALIAS, attributes2[1].Alias); Assert.IsNull(attributes2[1].Error); Assert.AreEqual(ATTRIBUTE2_PATH, attributes2[1].Path); Assert.IsTrue(attributes2[1].IsVisible); Assert.IsFalse(attributes2[1].IsHTML); Assert.AreEqual(0, Int32.Parse(attributes2[1].Position) % 10); TLocalizedValue[] names = attributes2[1].Name; Assert.AreEqual(2, names.Length); foreach (TLocalizedValue name in names) { if ("de".Equals(name.LanguageCode)) Assert.AreEqual(ATTRIBUTE2_NAME_DE + "updated", name.Value); else if ("en".Equals(name.LanguageCode)) Assert.AreEqual(ATTRIBUTE2_NAME_EN, name.Value); } Assert.IsTrue(Int32.Parse(attributes2[0].Position) < Int32.Parse(attributes2[1].Position)); Console.WriteLine("ProductTypeTest: testUpdateProductAttribute end"); }
/// <summary> /// test update /// </summary> public void testUpdate() { Console.WriteLine("ProductTypeTest: testUpdate start"); TUpdate_Input update1 = new TUpdate_Input(); update1.Path = NET_TEST1_PATH; update1.LayoutContentBundles = "BundlesTable"; TLocalizedValue name1_de = new TLocalizedValue(); name1_de.LanguageCode = "de"; name1_de.Value = NET_TEST1_NAME_DE + "updated"; update1.Name = new TLocalizedValue[] { name1_de }; TUpdate_Return[] productTypes = productTypeService.update(new TUpdate_Input[] { update1}); Assert.AreEqual(1, productTypes.Length); Assert.AreEqual(NET_TEST1_PATH, productTypes[0].Path); Assert.IsNull(productTypes[0].Error); Assert.IsTrue(productTypes[0].updated); TGetInfo_Return[] result = productTypeService.getInfo( new String[] { NET_TEST1_PATH }, new String[] { }, new String[] { "de", "en" }); Assert.AreEqual(1, result.Length); Assert.AreEqual(NET_TEST1_PATH, result[0].Path); Assert.IsNull(result[0].Error); Assert.AreEqual(NET_TEST1_ALIAS, result[0].Alias); Assert.AreEqual("BundlesTable", result[0].LayoutContentBundles); TLocalizedValue[] names = result[0].Name; Assert.AreEqual(2, names.Length); Assert.AreEqual("de", names[0].LanguageCode); Assert.AreEqual(NET_TEST1_NAME_DE + "updated", names[0].Value); Assert.AreEqual("en", names[1].LanguageCode); Assert.AreEqual(NET_TEST1_NAME_EN, names[1].Value); Console.WriteLine("ProductTypeTest: testUpdate end"); }