3
3
using NetoDotNET . Resources . Products ;
4
4
using NUnit . Framework ;
5
5
using System ;
6
+ using System . Collections . Generic ;
6
7
7
8
namespace NetoDotNET . Test
8
9
{
9
10
class ProductTests : NetoBaseTests
10
11
{
11
12
12
13
13
- private Item GetTestAddProduct ( )
14
+ private NewItem GetTestAddProduct ( )
14
15
{
15
16
Random random = new Random ( ) ;
16
- return new Item
17
+ return new NewItem
17
18
{
18
19
Name = "NetoDotNET.Test - Test Add Item" ,
19
20
SKU = random . Next ( 1000 , 99999 ) . ToString ( ) ,
20
21
DefaultPrice = 1.00m
21
22
} ;
22
23
}
23
24
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 ( )
25
41
{
26
42
Random random = new Random ( ) ;
27
43
string parentSKU = random . Next ( 10000 , 99999 ) . ToString ( ) ;
28
44
29
- return new Item [ ] {
30
- new Item {
45
+ return new NewItem [ ] {
46
+ new NewItem {
31
47
Name = "NetoDotNET.Test - Test Add Variable Item" ,
32
48
SKU = parentSKU ,
33
49
DefaultPrice = 1.00m ,
34
50
} ,
35
- new Item {
51
+ new NewItem {
36
52
Name = "NetoDotNET.Test - Test Add Variable Item" ,
37
53
SKU = random . Next ( 1000 , 9999 ) . ToString ( ) ,
38
54
DefaultPrice = 1.00m ,
39
55
ParentSKU = parentSKU
40
56
} ,
41
- new Item {
57
+ new NewItem {
42
58
Name = "NetoDotNET.Test - Test Add Variable Item" ,
43
59
SKU = random . Next ( 1000 , 9999 ) . ToString ( ) ,
44
60
DefaultPrice = 1.00m ,
@@ -113,7 +129,7 @@ public void Should_Add_Product()
113
129
{
114
130
var netoStore = GetStoreManager ( ) ;
115
131
116
- Item [ ] item = new Item [ ] {
132
+ NewItem [ ] item = new NewItem [ ] {
117
133
GetTestAddProduct ( )
118
134
} ;
119
135
@@ -124,6 +140,33 @@ public void Should_Add_Product()
124
140
Assert . AreEqual ( result . Item . Count , 1 ) ;
125
141
}
126
142
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
+
127
170
/// <summary>
128
171
/// Test add multiple products
129
172
/// </summary>
@@ -132,7 +175,7 @@ public void Should_Add_Multiple_Products()
132
175
{
133
176
var netoStore = GetStoreManager ( ) ;
134
177
135
- Item [ ] item = new Item [ ] {
178
+ NewItem [ ] item = new NewItem [ ] {
136
179
GetTestAddProduct ( ) ,
137
180
GetTestAddProduct ( ) ,
138
181
GetTestAddProduct ( )
@@ -153,7 +196,7 @@ public void Should_Add_Variable_Product()
153
196
{
154
197
var netoStore = GetStoreManager ( ) ;
155
198
156
- Item [ ] item = GetTestAddVariableProduct ( ) ;
199
+ NewItem [ ] item = GetTestAddVariableProduct ( ) ;
157
200
158
201
var result = netoStore . Products . AddItem ( item ) ;
159
202
0 commit comments