private FileAsMapping Convert(FileAsMappingType type)
        {
            switch (type)
            {
            case FileAsMappingType.None:
                return(FileAsMapping.None);

            case FileAsMappingType.LastCommaFirst:
                return(FileAsMapping.LastCommaFirst);

            case FileAsMappingType.FirstSpaceLast:
                return(FileAsMapping.FirstSpaceLast);

            case FileAsMappingType.Company:
                return(FileAsMapping.Company);

            case FileAsMappingType.LastCommaFirstCompany:
                return(FileAsMapping.LastCommaFirstCompany);

            case FileAsMappingType.CompanyLastFirst:
                return(FileAsMapping.CompanyLastFirst);

            case FileAsMappingType.LastFirst:
                return(FileAsMapping.LastFirst);

            case FileAsMappingType.LastFirstCompany:
                return(FileAsMapping.LastFirstCompany);

            case FileAsMappingType.CompanyLastCommaFirst:
                return(FileAsMapping.CompanyLastCommaFirst);

            case FileAsMappingType.LastFirstSuffix:
                return(FileAsMapping.LastFirstSuffix);

            case FileAsMappingType.LastSpaceFirstCompany:
                return(FileAsMapping.LastSpaceFirstCompany);

            case FileAsMappingType.CompanyLastSpaceFirst:
                return(FileAsMapping.CompanyLastSpaceFirst);

            case FileAsMappingType.LastSpaceFirst:
                return(FileAsMapping.LastSpaceFirst);

            case FileAsMappingType.DisplayName:
                return(FileAsMapping.DisplayName);

            case FileAsMappingType.FirstName:
                return(FileAsMapping.GivenName);

            case FileAsMappingType.LastFirstMiddleSuffix:
                return(FileAsMapping.LastFirstMiddleSuffix);

            case FileAsMappingType.LastName:
                return(FileAsMapping.LastName);

            case FileAsMappingType.Empty:
                return(FileAsMapping.Empty);

            default:
                throw new InvalidContactException();
            }
        }
        public void MSOXWSCONT_S01_TC04_VerifyContactItemWithFileAsMappingTypeEnums()
        {
            // The value count of enumeration "FileAsMappingType" is 13.
            int enumCount = 13;

            FileAsMappingType[] fileAsMappingTypes = new FileAsMappingType[enumCount];
            ContactItemType[] requestItems = new ContactItemType[enumCount];
            fileAsMappingTypes[0] = FileAsMappingType.None;
            fileAsMappingTypes[1] = FileAsMappingType.LastCommaFirst;
            fileAsMappingTypes[2] = FileAsMappingType.FirstSpaceLast;
            fileAsMappingTypes[3] = FileAsMappingType.Company;
            fileAsMappingTypes[4] = FileAsMappingType.LastCommaFirstCompany;
            fileAsMappingTypes[5] = FileAsMappingType.CompanyLastFirst;
            fileAsMappingTypes[6] = FileAsMappingType.LastFirst;
            fileAsMappingTypes[7] = FileAsMappingType.LastFirstCompany;
            fileAsMappingTypes[8] = FileAsMappingType.CompanyLastCommaFirst;
            fileAsMappingTypes[9] = FileAsMappingType.LastFirstSuffix;
            fileAsMappingTypes[10] = FileAsMappingType.LastSpaceFirstCompany;
            fileAsMappingTypes[11] = FileAsMappingType.CompanyLastSpaceFirst;
            fileAsMappingTypes[12] = FileAsMappingType.LastSpaceFirst;

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

                #region Step 1:Create the contact item with FileAsMappingType
                // Create a contact item with FileAsMappingType.
                requestItems[i] = this.CreateFileAsMappingTypeContact(fileAsMappingType);

                CreateItemResponseType createItemResponse = this.CallCreateItemOperation(requestItems[i]);

                // 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.IsTrue(
                    contacts[i].FileAsMappingSpecified,
                    "The FileAsMapping element in returned contact item should be specified.");

                Site.Assert.IsNotNull(
                    contacts[i].CompleteName,
                    "The returned CompleteName element in contact item should not be null.");
                #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_R130, Expected result: FileAsMapping is {0}, FileAs is {1}. Actual result: FileAsMapping is {2}, FileAs is {3}", requestItems[0].FileAsMapping, requestItems[0].FileAs, contacts[0].FileAsMapping, contacts[0].FileAs);

            // If the FileAsMapping element of contacts[0] equals to None, 
            // and the FileAs element in response equals that in request, which is not constructed by other properties,
            // then this requirement can be verified.
            bool isVerifyR130 = contacts[0].FileAsMapping == FileAsMappingType.None
                && contacts[0].FileAs == requestItems[0].FileAs;

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R130
            Site.CaptureRequirementIfIsTrue(
                isVerifyR130,
                130,
                @"[In t:FileAsMappingType Simple Type] None: Indicates that the FileAs value is not constructed from properties of other contacts (2), but is represented by a string, saved ""as is"".  ");

            // Add the debug information
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCONT_R133, Expected result: FileAsMapping is {0}, FileAs is {1}. Actual result: FileAsMapping is {2}, FileAs is {3}", requestItems[3].FileAsMapping, requestItems[3].CompanyName, contacts[3].FileAsMapping, contacts[3].FileAs);

            // If the FileAsMapping element of contacts[3] equals to Company, 
            // and the FileAs element equals to the company name,
            // then this requirement can be verified.
            bool isVerifyR133 = contacts[3].FileAsMapping == FileAsMappingType.Company
                && contacts[3].FileAs == contacts[3].CompanyName;

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R133
            Site.CaptureRequirementIfIsTrue(
                isVerifyR133,
                133,
                @"[In t:FileAsMappingType Simple Type] Company: Indicates that the company name is displayed.");
            #endregion
        }
        /// <summary>
        /// Create a contact item with enumeration value of FileAsMappingType.
        /// </summary>
        /// <param name="fileAsMappingType">The enumeration value of FileAsMappingType.</param>
        /// <returns>The contact item object.</returns>
        protected ContactItemType CreateFileAsMappingTypeContact(FileAsMappingType fileAsMappingType)
        {
            // Create a contact item type.
            ContactItemType item = new ContactItemType()
            {
                // Set the relevant properties on the contact.
                FileAsMapping = fileAsMappingType,
                FileAsMappingSpecified = true,

                // Set the information of complete name for the contact.
                DisplayName = Common.GenerateResourceName(
                        this.Site,
                        "DisplayName"),
                GivenName = Common.GenerateResourceName(
                        this.Site,
                        "GivenName"),
                MiddleName = Common.GenerateResourceName(
                        this.Site,
                        "MiddleName"),
                Surname = Common.GenerateResourceName(
                        this.Site,
                        "SurName"),
                Generation = Common.GenerateResourceName(
                        this.Site,
                        "SR."),

                // Set the information of company for the contact.
                Companies = new string[]
                {
                    Common.GenerateResourceName(
                        this.Site,
                        "Company")
                },

                CompanyName = Common.GenerateResourceName(
                        this.Site,
                        "Company"),
            };

            if (fileAsMappingType == FileAsMappingType.None)
            {
                item.FileAs = Common.GenerateResourceName(
                this.Site, "FirstContact");
            }

            return item;
        }