33using NetoDotNET . Resources . Products ;
44using NUnit . Framework ;
55using System ;
6+ using System . Collections . Generic ;
67
78namespace NetoDotNET . Test
89{
910 class ProductTests : NetoBaseTests
1011 {
1112
1213
13- private Item GetTestAddProduct ( )
14+ private NewItem GetTestAddProduct ( )
1415 {
1516 Random random = new Random ( ) ;
16- return new Item
17+ return new NewItem
1718 {
1819 Name = "NetoDotNET.Test - Test Add Item" ,
1920 SKU = random . Next ( 1000 , 99999 ) . ToString ( ) ,
2021 DefaultPrice = 1.00m
2122 } ;
2223 }
2324
24- private Item [ ] GetTestAddVariableProduct ( )
25+ private NewItem GetTestAddProductWithImages ( )
26+ {
27+ NewItem item = GetTestAddProduct ( ) ;
28+ item . Images = new Images
29+ {
30+ Image = new List < Image > {
31+ new Image { Name = "Main" , URL = "https://dummyimage.com/600x400/000/fff" } ,
32+ new Image { Name = "Alt 1" , URL = "https://dummyimage.com/600x400/000/fff" } ,
33+ new Image { Name = "Alt 2" , URL = "https://dummyimage.com/600x400/000/fff" }
34+ }
35+ } ;
36+
37+ return item ;
38+ }
39+
40+ private NewItem [ ] GetTestAddVariableProduct ( )
2541 {
2642 Random random = new Random ( ) ;
2743 string parentSKU = random . Next ( 10000 , 99999 ) . ToString ( ) ;
2844
29- return new Item [ ] {
30- new Item {
45+ return new NewItem [ ] {
46+ new NewItem {
3147 Name = "NetoDotNET.Test - Test Add Variable Item" ,
3248 SKU = parentSKU ,
3349 DefaultPrice = 1.00m ,
3450 } ,
35- new Item {
51+ new NewItem {
3652 Name = "NetoDotNET.Test - Test Add Variable Item" ,
3753 SKU = random . Next ( 1000 , 9999 ) . ToString ( ) ,
3854 DefaultPrice = 1.00m ,
3955 ParentSKU = parentSKU
4056 } ,
41- new Item {
57+ new NewItem {
4258 Name = "NetoDotNET.Test - Test Add Variable Item" ,
4359 SKU = random . Next ( 1000 , 9999 ) . ToString ( ) ,
4460 DefaultPrice = 1.00m ,
@@ -113,7 +129,7 @@ public void Should_Add_Product()
113129 {
114130 var netoStore = GetStoreManager ( ) ;
115131
116- Item [ ] item = new Item [ ] {
132+ NewItem [ ] item = new NewItem [ ] {
117133 GetTestAddProduct ( )
118134 } ;
119135
@@ -124,6 +140,33 @@ public void Should_Add_Product()
124140 Assert . AreEqual ( result . Item . Count , 1 ) ;
125141 }
126142
143+ /// <summary>
144+ /// Test add a product with 3 images
145+ /// </summary>
146+ [ Test ]
147+ public void Should_Add_Product_With_Images ( )
148+ {
149+ var netoStore = GetStoreManager ( ) ;
150+
151+ NewItem [ ] item = new NewItem [ ] {
152+ GetTestAddProductWithImages ( )
153+ } ;
154+
155+ var result = netoStore . Products . AddItem ( item ) ;
156+
157+ Assert . IsNotNull ( result ) ;
158+ Assert . AreEqual ( Ack . Success , result . Ack ) ;
159+ Assert . AreEqual ( result . Item . Count , 1 ) ;
160+
161+
162+ // Check for 3 images
163+ var filter = new GetItemFilter ( Convert . ToInt32 ( result . Item [ 0 ] . InventoryID ) ) ;
164+
165+ Item [ ] imageResult = netoStore . Products . GetItem ( filter ) ;
166+ Assert . AreEqual ( imageResult . Length , 1 ) ;
167+ Assert . AreEqual ( imageResult [ 0 ] . Images . Count , 3 ) ;
168+ }
169+
127170 /// <summary>
128171 /// Test add multiple products
129172 /// </summary>
@@ -132,7 +175,7 @@ public void Should_Add_Multiple_Products()
132175 {
133176 var netoStore = GetStoreManager ( ) ;
134177
135- Item [ ] item = new Item [ ] {
178+ NewItem [ ] item = new NewItem [ ] {
136179 GetTestAddProduct ( ) ,
137180 GetTestAddProduct ( ) ,
138181 GetTestAddProduct ( )
@@ -153,7 +196,7 @@ public void Should_Add_Variable_Product()
153196 {
154197 var netoStore = GetStoreManager ( ) ;
155198
156- Item [ ] item = GetTestAddVariableProduct ( ) ;
199+ NewItem [ ] item = GetTestAddVariableProduct ( ) ;
157200
158201 var result = netoStore . Products . AddItem ( item ) ;
159202
0 commit comments