Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        private ContactResponse CreateTestContact(NationBuilderSession session, long contactedPersonId, Contact contact)
        {
            var contactResponse = session.CreateContactToPerson(contactedPersonId, contact);

            Assert.AreEqual(contactResponse.contact.type_id, contact.type_id);
            Assert.AreEqual(contactResponse.contact.method, contact.method);
            Assert.AreEqual(contactResponse.contact.sender_id, contact.sender_id);
            Assert.AreEqual(contactResponse.contact.status, contact.status);
            Assert.AreEqual(contactResponse.contact.note, contact.note);

            bool foundContact = false;

            foreach (var personContact in session.GetContactsToPersonResults(contactedPersonId))
            {
                if (contactResponse.contact.Equals(personContact))
                {
                    foundContact = true;
                    break;
                }
            }
            Assert.IsTrue(foundContact);

            return contactResponse;
        }
Exemplo n.º 3
0
 public bool Equals(Contact comparand)
 {
     return Equals((object)comparand);
 }