public void CreateUpdateDestroyContactType() { using (var session = new NationBuilderSession(TestNationSlug, TestNationAccessToken)) { // Create a temporary test contact type: var aTestContactType = new ContactType() { name = "Test Contact Type Drive 2015", }; var newContactTypeResponse = session.CreateContactType(aTestContactType); Assert.IsTrue(newContactTypeResponse.contact_type.id.HasValue); Assert.AreEqual(newContactTypeResponse.contact_type.name, aTestContactType.name); var testContactType = newContactTypeResponse.contact_type; Assert.IsTrue(DoesContactTypeExist(session, testContactType)); // Update the contact type: testContactType.name += "+1"; var contactTypeResponse = session.UpdateContactType(testContactType.id.Value, testContactType); Assert.AreEqual(testContactType.id, contactTypeResponse.contact_type.id); Assert.AreEqual(testContactType.name, contactTypeResponse.contact_type.name); Assert.IsTrue(DoesContactTypeExist(session, testContactType)); // Destroy the contact type: session.DestroyContactType(testContactType.id.Value); // It seems that destruction is asynchronous, and doesn't occur imeediately: for (int c = 0; c < 5; ++c) { session.PersonMe(); } Assert.IsFalse(DoesContactTypeExist(session, testContactType)); } }
public void CreateContactToPerson() { using (var session = new NationBuilderSession(TestNationSlug, TestNationAccessToken)) { var testSender = session.PersonMe().person; Person testPerson; ContactType testContactType; ContactMethod testContactMethod; ContactStatus testContactStatus; CreateTestContactObjects(session, out testPerson, out testContactType, out testContactMethod, out testContactStatus); // Create a test contact to a person: var testContact = new Contact() { type_id = testContactType.id.Value, method = testContactMethod.api_name, sender_id = testSender.id.Value, status = testContactStatus.api_name, note = "Tasted well", }; var contactResponse = CreateTestContact(session, testPerson.id.Value, testContact); // Test destroying the contact type: session.DestroyContactType(testContactType.id.Value); //foreach (var contact in session.GetContactsToPersonResults(testPerson.id.Value)) //{ // Assert.AreNotEqual(contact.type_id, testContactType.id.Value); //} // Destroy temporary objects: session.DestroyPerson(testPerson.id.Value); } }
public void CreateUpdateDestroyContactType() { using (var session = new NationBuilderSession(TestNationSlug, TestNationAccessToken)) { // Create a temporary test contact type: var aTestContactType = new ContactType() { name = "Test Contact Type Drive 2015", }; var newContactTypeResponse = session.CreateContactType(aTestContactType); Assert.IsTrue(newContactTypeResponse.contact_type.id.HasValue); Assert.AreEqual(newContactTypeResponse.contact_type.name, aTestContactType.name); var testContactType = newContactTypeResponse.contact_type; Assert.IsTrue(DoesContactTypeExist(session, testContactType)); // Update the contact type: testContactType.name += "+1"; var contactTypeResponse = session.UpdateContactType(testContactType.id.Value, testContactType); Assert.AreEqual(testContactType.id, contactTypeResponse.contact_type.id); Assert.AreEqual(testContactType.name, contactTypeResponse.contact_type.name); Assert.IsTrue(DoesContactTypeExist(session, testContactType)); // Destroy the contact type: session.DestroyContactType(testContactType.id.Value); // It seems that destruction is asynchronous, and doesn't occur imeediately: for (int c = 0; c < 5; ++c) { session.PersonMe(); } Assert.IsFalse(DoesContactTypeExist(session, testContactType)); } }
public void CreateContactToPerson() { using (var session = new NationBuilderSession(TestNationSlug, TestNationAccessToken)) { var testSender = session.PersonMe().person; Person testPerson; ContactType testContactType; ContactMethod testContactMethod; ContactStatus testContactStatus; CreateTestContactObjects(session, out testPerson, out testContactType, out testContactMethod, out testContactStatus); // Create a test contact to a person: var testContact = new Contact() { type_id = testContactType.id.Value, method = testContactMethod.api_name, sender_id = testSender.id.Value, status = testContactStatus.api_name, note = "Tasted well", }; var contactResponse = CreateTestContact(session, testPerson.id.Value, testContact); // Test destroying the contact type: session.DestroyContactType(testContactType.id.Value); //foreach (var contact in session.GetContactsToPersonResults(testPerson.id.Value)) //{ // Assert.AreNotEqual(contact.type_id, testContactType.id.Value); //} // Destroy temporary objects: session.DestroyPerson(testPerson.id.Value); } }