Skip to content

Commit 950d8f0

Browse files
committed
whoops, didn't commit the tests!
1 parent a8f5cdd commit 950d8f0

File tree

3 files changed

+197
-32
lines changed

3 files changed

+197
-32
lines changed

MailJet.Client.Tests/ContactListTests.cs

Lines changed: 181 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public void CreateContactForList()
4343
var item = all.Data.Where(x => x.Name.StartsWith("Test")).FirstOrDefault();
4444
if (item == null)
4545
{
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();
4749
}
4850

4951
_testId = item.ID;
@@ -58,7 +60,7 @@ public void CreateContactForList()
5860
Name = name
5961
};
6062

61-
contact.AddProperty("SomeInfo", "TestProperty");
63+
contact.AddProperty("blah", "TestValueForBlahProperty");
6264

6365
var result = _client.CreateContactForList(_testId, contact);
6466
var resultItem = result.Data.Single();
@@ -69,7 +71,7 @@ public void CreateContactForList()
6971
[Test]
7072
public void CreateContactList()
7173
{
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));
7375
Assert.IsNotNull(result);
7476
var item = result.Data.Single();
7577
_testId = item.ID;
@@ -94,7 +96,9 @@ public void GetContactListById()
9496
item = all.Data.Where(x => x.Name.StartsWith("Test")).FirstOrDefault();
9597
if (item == null)
9698
{
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();
98102
}
99103

100104
_testId = item.ID;
@@ -117,7 +121,9 @@ public void GetContactListByAddress()
117121
item = all.Data.Where(x => x.Name.StartsWith("Test")).FirstOrDefault();
118122
if (item == null)
119123
{
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();
121127
}
122128

123129
_testId = item.ID;
@@ -139,7 +145,7 @@ public void DeleteContactListById()
139145
var item = all.Data.Where(x => x.Name.StartsWith("Test")).FirstOrDefault();
140146
if (item == null)
141147
{
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();
143149
}
144150

145151
_testId = item.ID;
@@ -159,7 +165,7 @@ public void DeleteContactListByAddress()
159165
var item = all.Data.Where(x => x.Name.StartsWith("Test")).FirstOrDefault();
160166
if (item == null)
161167
{
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();
163169
}
164170

165171
_testId = item.ID;
@@ -169,6 +175,174 @@ public void DeleteContactListByAddress()
169175
_testAddress = String.Empty;
170176
_testId = -1;
171177
}
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+
}
172346
}
173347
}
174348

MailJet.Client.Tests/ContactMetadataTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public void Setup()
3131
_client = new MailJetClient(publicKey, privateKey);
3232
}
3333

34+
[Test]
35+
public void GetContactData()
36+
{
37+
Assert.Ignore("Test Incomplete");
38+
var data = _client.GetContactData(21332);
39+
}
40+
3441
[Test]
3542
public void GetAllContactMetaData()
3643
{
Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
3-
4-
// Information about this assembly is defined by the following attributes.
5-
// Change them to the values specific to your project.
6-
7-
[assembly: AssemblyTitle ("MailJet.Client")]
8-
[assembly: AssemblyDescription ("MailJet Client for .NET")]
9-
[assembly: AssemblyConfiguration ("")]
10-
[assembly: AssemblyCompany ("")]
11-
[assembly: AssemblyProduct ("")]
12-
[assembly: AssemblyCopyright ("Ashley Medway")]
13-
[assembly: AssemblyTrademark ("")]
14-
[assembly: AssemblyCulture ("")]
15-
16-
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17-
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18-
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19-
20-
[assembly: AssemblyVersion ("0.1.0")]
21-
22-
// The following attributes are used to specify the signing key for the assembly,
23-
// if desired. See the Mono documentation for more information about signing.
24-
25-
//[assembly: AssemblyDelaySign(false)]
26-
//[assembly: AssemblyKeyFile("")]
272

3+
[assembly: AssemblyTitle("MailJet.Client")]
4+
[assembly: AssemblyDescription("MailJet Client for .NET")]
5+
[assembly: AssemblyConfiguration("")]
6+
[assembly: AssemblyCompany("")]
7+
[assembly: AssemblyProduct("")]
8+
[assembly: AssemblyCopyright("Ashley Medway")]
9+
[assembly: AssemblyTrademark("")]
10+
[assembly: AssemblyCulture("")]
11+
[assembly: AssemblyVersion("1.3.0")]

0 commit comments

Comments
 (0)