private EmailAddressIndex Convert(EmailAddressKeyType type)
        {
            switch (type)
            {
            case EmailAddressKeyType.EmailAddress1:
                return(EmailAddressIndex.Email1);

            case EmailAddressKeyType.EmailAddress2:
                return(EmailAddressIndex.Email2);

            case EmailAddressKeyType.EmailAddress3:
                return(EmailAddressIndex.Email3);

            default:
                throw new InvalidContactException();
            }
        }
        public void MSOXWSCONT_S01_TC03_VerifyContactItemWithEmailAddressKeyTypeEnums()
        {
            // The value count of enumeration "EmailAddressKeyType" is 3.
            int enumCount = 3;
            EmailAddressKeyType[] emailAddressKeyTypes = new EmailAddressKeyType[enumCount];

            emailAddressKeyTypes[0] = EmailAddressKeyType.EmailAddress1;
            emailAddressKeyTypes[1] = EmailAddressKeyType.EmailAddress2;
            emailAddressKeyTypes[2] = EmailAddressKeyType.EmailAddress3;

            // Define a contact array to store the contact items got from GetItem operation response.
            // Each contact should contain an EmailAddressKeyType value as its element's value.
            ContactItemType[] contacts = new ContactItemType[enumCount];
            for (int i = 0; i < enumCount; i++)
            {
                EmailAddressKeyType emailAddressKeyType = emailAddressKeyTypes[i];

                #region Step 1:Create the contact item with EmailAddressKeyType
                // Create a contact item with EmailAddressKeyType
                ContactItemType item = this.BuildContactItemWithEmailAddress(emailAddressKeyType);
                CreateItemResponseType createItemResponse = this.CallCreateItemOperation(item);

                // Check the response.
                Common.CheckOperationSuccess(createItemResponse, 1, this.Site);
                #endregion

                #region Step 2:Get the contact item.
                // The contact item to get.
                ItemIdType[] itemIds = Common.GetItemIdsFromInfoResponse(createItemResponse);

                GetItemResponseType getItemResponse = this.CallGetItemOperation(itemIds);

                // Check the response.
                Common.CheckOperationSuccess(getItemResponse, 1, this.Site);

                ContactItemType[] getItems = Common.GetItemsFromInfoResponse<ContactItemType>(getItemResponse);

                Site.Assert.AreEqual<int>(
                    1,
                    getItems.GetLength(0),
                    "One contact item should be returned!");

                contacts[i] = getItems[0];

                Site.Assert.IsNotNull(
                    contacts[i],
                    "The returned contact item should not be null.");

                Site.Assert.IsNotNull(
                    contacts[i].EmailAddresses,
                    "The EmailAddresses element in returned contact item should not be null.");

                Site.Assert.AreEqual<int>(
                    1,
                    contacts[i].EmailAddresses.GetLength(0),
                    "One entry of EmailAddresses element should be returned!");
                #endregion
            }

            #region Capture Code

            this.Site.Assert.IsTrue(
                this.IsSchemaValidated,
                "The schema should be validated! Expected result: {0}, Actual result: {1}",
                true.ToString(),
                this.IsSchemaValidated.ToString());

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCONT_R124");

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R124
            Site.CaptureRequirementIfAreEqual<EmailAddressKeyType>(
                EmailAddressKeyType.EmailAddress1,
                contacts[0].EmailAddresses[0].Key,
                124,
                @"[In t:EmailAddressKeyType Simple Type] EmailAddress1: Identifies the first e-mail address for the contact (2).");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCONT_R125");

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R125
            Site.CaptureRequirementIfAreEqual<EmailAddressKeyType>(
                EmailAddressKeyType.EmailAddress2,
                contacts[1].EmailAddresses[0].Key,
                125,
                @"[In t:EmailAddressKeyType Simple Type] EmailAddress2: Identifies the second e-mail address for the contact (2).");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCONT_R126");

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R126
            Site.CaptureRequirementIfAreEqual<EmailAddressKeyType>(
                EmailAddressKeyType.EmailAddress3,
                contacts[2].EmailAddresses[0].Key,
                126,
                @"[In t:EmailAddressKeyType Simple Type] EmailAddress3: Identifies the third e-mail address for the contact (2).");
            #endregion
        }
 /// <summary>
 /// Factory method for creating an email address dictionary field uri
 /// </summary>
 /// <param name="fieldIndex">Email address field index</param>
 /// <returns>Indexed Field URI</returns>
 /// 
 public static PathToIndexedFieldType CreateEmailAddress(EmailAddressKeyType fieldIndex)
 {
     return new PathToIndexedFieldType(DictionaryURIType.contactsEmailAddress, fieldIndex.ToString());
 }
 /// <summary>
 /// Build a contact item with enumeration value of EmailAddressKeyType.
 /// </summary>
 /// <param name="emailAddressKeyType">The enumeration value of EmailAddressKeyType.</param>
 /// <returns>The contact item object.</returns>
 protected ContactItemType BuildContactItemWithEmailAddress(EmailAddressKeyType emailAddressKeyType)
 {
     // Create a contact item type.
     ContactItemType item = new ContactItemType()
     {
         // Set a single e-mail address for the contact.
         EmailAddresses = new EmailAddressDictionaryEntryType[]
         {
             new EmailAddressDictionaryEntryType()
             {
                 Value = Common.GenerateResourceName(this.Site, "EmailAddress") + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site),
                 Key = emailAddressKeyType,
             }
         }
     };
     return item;
 }