예제 #1
0
        public void TestCustomerContactAddEmptyPhone()
        {
            int CustomerID = 77777777; // Fake ID for Mock testing
            Client client = getApiClient();
            ContactResponse contact = new ContactResponse();
            contact.FirstName = "Contact";
            contact.LastName = "Contactson";
            contact.Salutation = "Mr.";
            contact.Title = "Title";

            PhoneNumberResponse phone = new PhoneNumberResponse();
            phone.Number = "";
            phone.Type = PhoneNumberResponse.NumberType.Business;
            contact.PhoneNumbers.Add(phone);

            ContactResponse response = client.CustomerContactAdd(CustomerID, contact, true);

            foreach (PhoneNumberResponse responsePhone in response.PhoneNumbers)
            {
                if (responsePhone.Type == phone.Type)
                {
                    phone.PhoneNumberID = responsePhone.PhoneNumberID;
                    Assert.AreEqual<string>(responsePhone.Number, "none");
                    break;
                }
            }
        }
 public void setPhoneNumber(string Number, PhoneNumberResponse.NumberType type)
 {
     PhoneNumberResponse phoneNumberToChange = this.getPhoneNumber(type);
     phoneNumberToChange.Number = Number;
 }
예제 #3
0
        public void TestCustomerContactAdd()
        {
            int CustomerID = 77777777; // Fake ID for Mock testing
            Client client = getApiClient();
            ContactResponse contact = new ContactResponse();
            contact.FirstName = "Contact";
            contact.LastName = "Contactson";
            contact.Salutation = "Mr.";
            contact.Title = "Title";

            PhoneNumberResponse phone = new PhoneNumberResponse();
            phone.Number = "555-0035";
            phone.Type = PhoneNumberResponse.NumberType.Business;
            contact.PhoneNumbers.Add(phone);

            ContactResponse response = client.CustomerContactAdd(CustomerID, contact, true);

            foreach (PhoneNumberResponse responsePhone in response.PhoneNumbers)
            {
                if (responsePhone.Type == phone.Type)
                {
                    phone.PhoneNumberID = responsePhone.PhoneNumberID;
                    Assert.IsTrue(responsePhone.Equals(phone));
                    break;
                }

            }

            // The response comes with the 4 phone number entries
            response.PhoneNumbers = contact.PhoneNumbers;

            contact.ContactID = response.ContactID;

            Assert.IsTrue(response.Equals(contact));
        }
 public PhoneNumberResponse getPhoneNumber(PhoneNumberResponse.NumberType type)
 {
     PhoneNumberResponse phoneNumber = null;
     foreach (PhoneNumberResponse phone in this.PhoneNumbers)
     {
         if (phone.Type == type)
         {
             phoneNumber = phone;
             break;
         }
     }
     if (phoneNumber == null)
     {
         phoneNumber = new PhoneNumberResponse();
         phoneNumber.Type = type;
     }
     return phoneNumber;
 }