/// <summary>
        /// Search contact by contact id (not contact uid).
        /// </summary>
        /// <param name="contactID"></param>
        /// <returns></returns>
        private contactListResponse SearchByContactID(string contactID)
        {
            NameValueCollection queries = new NameValueCollection();

            queries.Add("contactid", contactID);
            string url = RestProxy.MakeUrl("ContactList");

            url += "&" + Util.ToQueryString(queries);
            string xmlFragment           = HttpUtils.Get(url);
            contactListResponse response = (contactListResponse)XmlSerializationUtils.Deserialize(typeof(contactListResponse), xmlFragment);

            return(response);
        }
        /// <summary>
        /// Search contact, Carl O'Neil from O'Neil Capital.
        /// </summary>
        /// <returns></returns>
        private contactListResponse SearchCarl()
        {
            NameValueCollection queries = new NameValueCollection();

            queries.Add("givenname", "carl");                   // AKA first name.
            queries.Add("familyName", "o'neil");                // AKA last name.
            queries.Add("organisationName", "o'neil capital");  // AKA organisation, company.
            string url = RestProxy.MakeUrl("ContactList");

            url += "&" + Util.ToQueryString(queries);

            string xmlFragment           = HttpUtils.Get(url);
            contactListResponse response = (contactListResponse)XmlSerializationUtils.Deserialize(typeof(contactListResponse), xmlFragment);

            return(response);
        }
        public void SearchByContactID()
        {
            contactListResponse response = this.SearchCarl();

            if (response.contactList.Count == 0)
            {
                this.AddCarl();
            }

            response = this.SearchByContactID("GLD879");        // Note this is the contact id field, not contact uid.
            Assert.AreEqual(1, response.contactList.Count, "Incorrect number of contacts found.");

            contactListItem cli = response.contactList[0];

            Assert.AreEqual("Carl", cli.givenName, "Incorrect given name");
            Assert.AreEqual("O'Neil", cli.familyName, "Incorrect family name");
            Assert.AreEqual("O'Neil Capital", cli.organisationName, "Incorrect organisation name");
            Assert.AreEqual("O'Neil", cli.customField1, "Incorrect custom field 1");
            Assert.AreEqual("GLD879", cli.contactID, "Incorrect contact id");
        }
        public void SearchByFirstNameLastNameAndOrgName()
        {
            // Look up
            // Is Carl O'Neil from O'Neil Capital already added?
            // If not add it.
            // If yes, ensure details are correct (first name, last name, org name, contact id, cf1 and cf2).
            contactListResponse response = this.SearchCarl();

            if (response.contactList.Count == 0)
            {
                this.AddCarl();
            }

            response = this.SearchCarl();
            Assert.AreEqual(1, response.contactList.Count, "Incorrect number of contacts found.");

            contactListItem cli = response.contactList[0];

            Assert.AreEqual("Carl", cli.givenName, "Incorrect given name");
            Assert.AreEqual("O'Neil", cli.familyName, "Incorrect family name");
            Assert.AreEqual("O'Neil Capital", cli.organisationName, "Incorrect organisation name");
            Assert.AreEqual("O'Neil", cli.customField1, "Incorrect custom field 1");
            Assert.AreEqual("GLD879", cli.contactID, "Incorrect contact id");
        }