@@ -43,7 +43,9 @@ public void CreateContactForList()
43
43
var item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
44
44
if ( item == null )
45
45
{
46
- Assert . Fail ( "Could not find a test item to test this method" ) ;
46
+ CreateContactList ( ) ;
47
+ all = _client . GetAllContactLists ( ) ;
48
+ item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
47
49
}
48
50
49
51
_testId = item . ID ;
@@ -58,7 +60,7 @@ public void CreateContactForList()
58
60
Name = name
59
61
} ;
60
62
61
- contact . AddProperty ( "SomeInfo " , "TestProperty " ) ;
63
+ contact . AddProperty ( "blah " , "TestValueForBlahProperty " ) ;
62
64
63
65
var result = _client . CreateContactForList ( _testId , contact ) ;
64
66
var resultItem = result . Data . Single ( ) ;
@@ -69,7 +71,7 @@ public void CreateContactForList()
69
71
[ Test ]
70
72
public void CreateContactList ( )
71
73
{
72
- var result = _client . CreateContactList ( String . Format ( "Test {0:dd-MM-yyyy hh:mm:ss }" , DateTime . UtcNow ) ) ;
74
+ var result = _client . CreateContactList ( String . Format ( "Test {0:o }" , DateTime . UtcNow ) ) ;
73
75
Assert . IsNotNull ( result ) ;
74
76
var item = result . Data . Single ( ) ;
75
77
_testId = item . ID ;
@@ -94,7 +96,9 @@ public void GetContactListById()
94
96
item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
95
97
if ( item == null )
96
98
{
97
- Assert . Fail ( "Could not find a test item to test this method" ) ;
99
+ CreateContactList ( ) ;
100
+ all = _client . GetAllContactLists ( ) ;
101
+ item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
98
102
}
99
103
100
104
_testId = item . ID ;
@@ -117,7 +121,9 @@ public void GetContactListByAddress()
117
121
item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
118
122
if ( item == null )
119
123
{
120
- Assert . Fail ( "Could not find a test item to test this method" ) ;
124
+ CreateContactList ( ) ;
125
+ all = _client . GetAllContactLists ( ) ;
126
+ item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
121
127
}
122
128
123
129
_testId = item . ID ;
@@ -139,7 +145,7 @@ public void DeleteContactListById()
139
145
var item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
140
146
if ( item == null )
141
147
{
142
- item = _client . CreateContactList ( String . Format ( "Test {0:dd-MM-yyyy hh:mm:ss }" , DateTime . UtcNow ) ) . Data . Single ( ) ;
148
+ item = _client . CreateContactList ( String . Format ( "Test {0:o }" , DateTime . UtcNow ) ) . Data . Single ( ) ;
143
149
}
144
150
145
151
_testId = item . ID ;
@@ -159,7 +165,7 @@ public void DeleteContactListByAddress()
159
165
var item = all . Data . Where ( x => x . Name . StartsWith ( "Test" ) ) . FirstOrDefault ( ) ;
160
166
if ( item == null )
161
167
{
162
- item = _client . CreateContactList ( String . Format ( "Test {0:dd-MM-yyyy hh:mm:ss }" , DateTime . UtcNow ) ) . Data . Single ( ) ;
168
+ item = _client . CreateContactList ( String . Format ( "Test {0:o }" , DateTime . UtcNow ) ) . Data . Single ( ) ;
163
169
}
164
170
165
171
_testId = item . ID ;
@@ -169,6 +175,174 @@ public void DeleteContactListByAddress()
169
175
_testAddress = String . Empty ;
170
176
_testId = - 1 ;
171
177
}
178
+
179
+ [ Test ]
180
+ public void ListRecipient_All ( )
181
+ {
182
+ var result = _client . GetListRecipient ( ) ;
183
+ Assert . IsNotNull ( result ) ;
184
+ Assert . IsNotNull ( result . Data ) ;
185
+ Assert . AreEqual ( result . Count , result . Data . Count ) ;
186
+ }
187
+
188
+ [ Test ]
189
+ public void ListRecipient_IsActive ( )
190
+ {
191
+ var result = _client . GetListRecipient ( IsActive : true ) ;
192
+ Assert . IsNotNull ( result ) ;
193
+ Assert . IsNotNull ( result . Data ) ;
194
+ Assert . AreEqual ( result . Count , result . Data . Count ) ;
195
+ Assert . IsTrue ( result . Data . All ( x => x . IsActive ) ) ;
196
+ }
197
+
198
+ [ Test ]
199
+ public void ListRecipient_IsBlocked ( )
200
+ {
201
+ //TODO: Write test
202
+ Assert . Ignore ( "Not sure how to test" ) ;
203
+ }
204
+
205
+ [ TestCase ( true ) ]
206
+ public void ListRecipient_ByContactId ( bool firstrun )
207
+ {
208
+ try
209
+ {
210
+ var result = _client . GetListRecipient ( ) ;
211
+ var item = result . Data . First ( ) ;
212
+ var api = _client . GetListRecipient ( ContactId : item . ContactID ) ;
213
+ Assert . IsNotNull ( api ) ;
214
+ Assert . IsNotNull ( api . Data ) ;
215
+ Assert . AreEqual ( api . Count , api . Data . Count ) ;
216
+ Assert . IsTrue ( api . Data . All ( x => x . ContactID == item . ContactID ) ) ;
217
+ }
218
+ catch ( InvalidOperationException )
219
+ {
220
+ if ( firstrun )
221
+ {
222
+ CreateContactForList ( ) ;
223
+ ListRecipient_ByContactId ( false ) ;
224
+ }
225
+ else
226
+ {
227
+ throw ;
228
+ }
229
+ }
230
+ }
231
+
232
+ [ Test ]
233
+ public void ListRecipient_ByContactEmail ( )
234
+ {
235
+ Assert . Ignore ( "Test not complete, need to be able to query /contact" ) ;
236
+ //var result = _client.GetListRecipient();
237
+ //var item = result.Data.First();
238
+ //TODO: remove hardcoded test
239
+ var api = _client . GetListRecipient ( ContactEmail : "[email protected] " ) ;
240
+ Assert . IsNotNull ( api ) ;
241
+ Assert . IsNotNull ( api . Data ) ;
242
+ Assert . AreEqual ( api . Count , api . Data . Count ) ;
243
+ //TODO: remove hardcoded test
244
+ Assert . IsTrue ( api . Data . All ( x => x . ContactID == 1689224808 ) ) ;
245
+ }
246
+
247
+ [ Test ]
248
+ public void ListRecipient_ByContactListId ( )
249
+ {
250
+ var result = _client . GetListRecipient ( ) ;
251
+ var item = result . Data . First ( ) ;
252
+ var api = _client . GetListRecipient ( ContactsListId : item . ListID ) ;
253
+ Assert . IsNotNull ( api ) ;
254
+ Assert . IsNotNull ( api . Data ) ;
255
+ Assert . AreEqual ( api . Count , api . Data . Count ) ;
256
+ Assert . IsTrue ( api . Data . All ( x => x . ListID == item . ListID ) ) ;
257
+ }
258
+
259
+ [ Test ]
260
+ public void ListRecipient_ByContactListIdAndContactId ( )
261
+ {
262
+ var result = _client . GetListRecipient ( ) ;
263
+ var item = result . Data . First ( ) ;
264
+ var api = _client . GetListRecipient ( ContactsListId : item . ListID , ContactId : item . ContactID ) ;
265
+ Assert . IsNotNull ( api ) ;
266
+ Assert . IsNotNull ( api . Data ) ;
267
+ Assert . AreEqual ( api . Count , api . Data . Count ) ;
268
+ Assert . IsTrue ( api . Data . All ( x => x . ListID == item . ListID && x . ContactID == item . ContactID ) ) ;
269
+ }
270
+
271
+
272
+ [ Test ]
273
+ public void ListRecipient_ByContactListIdAndContactIdAndUnSub_False ( )
274
+ {
275
+ var result = _client . GetListRecipient ( ) ;
276
+ var item = result . Data . First ( ) ;
277
+ var api = _client . GetListRecipient ( ContactsListId : item . ListID , ContactId : item . ContactID , Unsub : false ) ;
278
+ Assert . IsNotNull ( api ) ;
279
+ Assert . IsNotNull ( api . Data ) ;
280
+ Assert . AreEqual ( api . Count , api . Data . Count ) ;
281
+ Assert . IsTrue ( api . Data . All ( x => x . ListID == item . ListID && x . ContactID == item . ContactID && ! x . IsUnsubscribed ) ) ;
282
+ }
283
+
284
+ [ Test ]
285
+ public void ListRecipient_IgnoreDeleted ( )
286
+ {
287
+ //TODO: Write test
288
+ Assert . Ignore ( "Not sure how to test" ) ;
289
+ }
290
+
291
+ [ Test ]
292
+ public void ListRecipient_ByLastActivityAt ( )
293
+ {
294
+ //TODO: Write test
295
+ Assert . Ignore ( "Not sure how to test" ) ;
296
+ }
297
+
298
+ [ Test ]
299
+ public void ListRecipient_ByListName ( )
300
+ {
301
+ Assert . Ignore ( "Test not complete, need to be able to query /contact" ) ;
302
+ //var result = _client.GetListRecipient();
303
+ //var item = result.Data.First();
304
+ //TODO: remove hardcoded test
305
+ var api = _client . GetListRecipient ( ListName : "Test 07-03-2016 09:05:45" ) ;
306
+ Assert . IsNotNull ( api ) ;
307
+ Assert . IsNotNull ( api . Data ) ;
308
+ Assert . AreEqual ( api . Count , api . Data . Count ) ;
309
+ //TODO: remove hardcoded test
310
+ Assert . IsTrue ( api . Data . All ( x => x . ListID == 1486008 ) ) ;
311
+ }
312
+
313
+ [ Test ]
314
+ public void ListRecipient_ByOpenedEmail ( )
315
+ {
316
+ //TODO: Write test
317
+ Assert . Ignore ( "Not sure how to test" ) ;
318
+ }
319
+
320
+ [ Test ]
321
+ public void ListRecipient_ByStatus ( )
322
+ {
323
+ //TODO: Write test
324
+ Assert . Ignore ( "Not sure how to test" ) ;
325
+ }
326
+
327
+ [ Test ]
328
+ public void ListRecipient_ByUnSub_False ( )
329
+ {
330
+ var result = _client . GetListRecipient ( Unsub : false ) ;
331
+ Assert . IsNotNull ( result ) ;
332
+ Assert . IsNotNull ( result . Data ) ;
333
+ Assert . AreEqual ( result . Count , result . Data . Count ) ;
334
+ Assert . IsTrue ( result . Data . All ( x => ! x . IsUnsubscribed ) ) ;
335
+ }
336
+
337
+ [ Test ]
338
+ public void ListRecipient_ByUnSub_True ( )
339
+ {
340
+ var result = _client . GetListRecipient ( Unsub : true ) ;
341
+ Assert . IsNotNull ( result ) ;
342
+ Assert . IsNotNull ( result . Data ) ;
343
+ Assert . AreEqual ( result . Count , result . Data . Count ) ;
344
+ Assert . IsTrue ( result . Data . All ( x => x . IsUnsubscribed ) ) ;
345
+ }
172
346
}
173
347
}
174
348
0 commit comments