insightly-api
Diff Revisions
8
vs
9
for /trunk/UnitTestInsightly/ContactAddTest.cs
|
@@ -162,6 +162,65 @@ |
162 |
162 |
|
} |
163 |
163 |
|
|
164 |
164 |
|
/// <summary> |
|
165 |
+ |
/// Test an existing contact will not be added again. |
|
166 |
+ |
/// </summary> |
|
167 |
+ |
[TestMethod] |
|
168 |
+ |
public void DoNotAddExistingContact() |
|
169 |
+ |
{ |
|
170 |
+ |
InsightlyAPI api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
|
171 |
+ |
|
|
172 |
+ |
ContactInfo newInfo = new ContactInfo(); |
|
173 |
+ |
newInfo.TYPE = ContactInfo.InfoType.Email.GetDescription(); |
|
174 |
+ |
newInfo.LABEL = ContactInfo.InfoLabelEmail.Work.GetDescription(); |
|
175 |
+ |
newInfo.DETAIL = "johnsmith@smith.net"; |
|
176 |
+ |
|
|
177 |
+ |
Contact newContact = new Contact(); |
|
178 |
+ |
newContact.FIRST_NAME = "John"; |
|
179 |
+ |
newContact.LAST_NAME = "Smith"; |
|
180 |
+ |
newContact.CONTACTINFOS = new List<ContactInfo> { newInfo }; |
|
181 |
+ |
|
|
182 |
+ |
var addResult = api.AddNewContactIfNotExists(newContact); |
|
183 |
+ |
|
|
184 |
+ |
Assert.IsFalse(addResult.NewContactAdded); |
|
185 |
+ |
|
|
186 |
+ |
} |
|
187 |
+ |
|
|
188 |
+ |
[TestMethod] |
|
189 |
+ |
public void AddBasicContactRecordUsingExistsCheck() |
|
190 |
+ |
{ |
|
191 |
+ |
Contact addedContact = null; |
|
192 |
+ |
InsightlyAPI api = new InsightlyAPI(APIUser.PLAIN_API_KEY); |
|
193 |
+ |
|
|
194 |
+ |
try |
|
195 |
+ |
{ |
|
196 |
+ |
ContactInfo newInfo = new ContactInfo(); |
|
197 |
+ |
newInfo.TYPE = ContactInfo.InfoType.Email.GetDescription(); |
|
198 |
+ |
newInfo.LABEL = ContactInfo.InfoLabelEmail.Work.GetDescription(); |
|
199 |
+ |
newInfo.DETAIL = "mary@smith.net"; |
|
200 |
+ |
|
|
201 |
+ |
Contact newContact = new Contact(); |
|
202 |
+ |
newContact.SALUTATION = "Ms"; |
|
203 |
+ |
newContact.FIRST_NAME = "Mary"; |
|
204 |
+ |
newContact.LAST_NAME = "Jones"; |
|
205 |
+ |
newContact.CONTACTINFOS = new List<ContactInfo> { newInfo }; |
|
206 |
+ |
|
|
207 |
+ |
var addResult = api.AddNewContactIfNotExists(newContact); |
|
208 |
+ |
|
|
209 |
+ |
Assert.IsTrue(addResult.NewContactAdded); |
|
210 |
+ |
|
|
211 |
+ |
addedContact = addResult.Contact; |
|
212 |
+ |
|
|
213 |
+ |
Assert.AreEqual(newContact.SALUTATION, addedContact.SALUTATION); |
|
214 |
+ |
Assert.AreEqual(newContact.FIRST_NAME, addedContact.FIRST_NAME); |
|
215 |
+ |
Assert.AreEqual(newContact.LAST_NAME, addedContact.LAST_NAME); |
|
216 |
+ |
} |
|
217 |
+ |
finally |
|
218 |
+ |
{ |
|
219 |
+ |
DeleteContact(api, addedContact); |
|
220 |
+ |
} |
|
221 |
+ |
} |
|
222 |
+ |
|
|
223 |
+ |
/// <summary> |
165 |
224 |
|
/// Test exception raised when trying to add and invalid contact. |
166 |
225 |
|
/// </summary> |
167 |
226 |
|
[TestMethod] |