Exemple #1
0
        public static PhoneNumberDictionaryEntryType ParcePhone(string type, string value)
        {
            PhoneNumberKeyType key = PhoneNumberKeyType.CompanyMainPhone;

            switch (type)
            {
            case PhoneTypesAttribute.Business1:
                key = PhoneNumberKeyType.BusinessPhone;
                break;

            case PhoneTypesAttribute.Business2:
                key = PhoneNumberKeyType.BusinessPhone2;
                break;

            case PhoneTypesAttribute.Business3:
                key = PhoneNumberKeyType.OtherTelephone;
                break;

            case PhoneTypesAttribute.BusinessAssistant1:
                key = PhoneNumberKeyType.AssistantPhone;
                break;

            case PhoneTypesAttribute.BusinessFax:
                key = PhoneNumberKeyType.BusinessFax;
                break;

            case PhoneTypesAttribute.HomeFax:
                key = PhoneNumberKeyType.HomeFax;
                break;

            case PhoneTypesAttribute.Cell:
                key = PhoneNumberKeyType.MobilePhone;
                break;

            case PhoneTypesAttribute.Home:
                key = PhoneNumberKeyType.HomePhone;
                break;
            }

            PhoneNumberDictionaryEntryType phone = new PhoneNumberDictionaryEntryType();

            phone.Key   = key;
            phone.Value = value;
            return(phone);
        }
        public void MSOXWSCONT_S01_TC06_VerifyContactItemWithPhoneNumbersKeyTypeEnums()
        {
            // The value count of enumeration "PhoneNumberKeyType" is 19.
            int enumCount = 19;
            PhoneNumberKeyType[] phoneNumberKeyTypes = new PhoneNumberKeyType[enumCount];

            phoneNumberKeyTypes[0] = PhoneNumberKeyType.AssistantPhone;
            phoneNumberKeyTypes[1] = PhoneNumberKeyType.BusinessFax;
            phoneNumberKeyTypes[2] = PhoneNumberKeyType.BusinessPhone;
            phoneNumberKeyTypes[3] = PhoneNumberKeyType.BusinessPhone2;
            phoneNumberKeyTypes[4] = PhoneNumberKeyType.Callback;
            phoneNumberKeyTypes[5] = PhoneNumberKeyType.CarPhone;
            phoneNumberKeyTypes[6] = PhoneNumberKeyType.CompanyMainPhone;
            phoneNumberKeyTypes[7] = PhoneNumberKeyType.HomeFax;
            phoneNumberKeyTypes[8] = PhoneNumberKeyType.HomePhone;
            phoneNumberKeyTypes[9] = PhoneNumberKeyType.HomePhone2;
            phoneNumberKeyTypes[10] = PhoneNumberKeyType.Isdn;
            phoneNumberKeyTypes[11] = PhoneNumberKeyType.MobilePhone;
            phoneNumberKeyTypes[12] = PhoneNumberKeyType.OtherFax;
            phoneNumberKeyTypes[13] = PhoneNumberKeyType.OtherTelephone;
            phoneNumberKeyTypes[14] = PhoneNumberKeyType.Pager;
            phoneNumberKeyTypes[15] = PhoneNumberKeyType.PrimaryPhone;
            phoneNumberKeyTypes[16] = PhoneNumberKeyType.RadioPhone;
            phoneNumberKeyTypes[17] = PhoneNumberKeyType.Telex;
            phoneNumberKeyTypes[18] = PhoneNumberKeyType.TtyTddPhone;

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

                // Create a contact item.
                ContactItemType item = new ContactItemType()
                {
                    // Set a single phone number for the contact.
                    PhoneNumbers = new PhoneNumberDictionaryEntryType[]
                    {
                        new PhoneNumberDictionaryEntryType()
                        {
                            Value = "123456789",
                            Key = phoneNumberKeyType,
                        }
                    }
                };

                #region Step 1:Create the contact item with PhoneNumberKeyType
                // Call CreateItem operation.
                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].PhoneNumbers,
                    "The PhoneNumbers element in returned contact item should not be null.");

                Site.Assert.AreEqual<int>(
                    1,
                    contacts[i].PhoneNumbers.GetLength(0),
                    "One entry of PhoneNumbers 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_R157");

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R157
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.AssistantPhone,
                contacts[0].PhoneNumbers[0].Key,
                157,
                @"[In t:PhoneNumberKeyType Simple Type] AssistantPhone: Identifies the telephone number as the assistant's telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R158
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.BusinessFax,
                contacts[1].PhoneNumbers[0].Key,
                158,
                @"[In t:PhoneNumberKeyType Simple Type] BusinessFax: Identifies the telephone number as a business fax number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R159
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.BusinessPhone,
                contacts[2].PhoneNumbers[0].Key,
                159,
                @"[In t:PhoneNumberKeyType Simple Type] BusinessPhone: Identifies the telephone number as a business telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R160
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.BusinessPhone2,
                contacts[3].PhoneNumbers[0].Key,
                160,
                @"[In t:PhoneNumberKeyType Simple Type] BusinessPhone2: Identifies the telephone number as a second business telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R161
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.Callback,
                contacts[4].PhoneNumbers[0].Key,
                161,
                @"[In t:PhoneNumberKeyType Simple Type] Callback: Identifies the telephone number as a callback number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R162
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.CarPhone,
                contacts[5].PhoneNumbers[0].Key,
                162,
                @"[In t:PhoneNumberKeyType Simple Type] CarPhone: Identifies the telephone number as a car telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R163
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.CompanyMainPhone,
                contacts[6].PhoneNumbers[0].Key,
                163,
                @"[In t:PhoneNumberKeyType Simple Type] CompanyMainPhone: Identifies the telephone number as the company's main telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R164
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.HomeFax,
                contacts[7].PhoneNumbers[0].Key,
                164,
                @"[In t:PhoneNumberKeyType Simple Type] HomeFax: Identifies the telephone number as a home fax number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R165
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.HomePhone,
                contacts[8].PhoneNumbers[0].Key,
                165,
                @"[In t:PhoneNumberKeyType Simple Type] HomePhone: Identifies the telephone number as a home telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R166
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.HomePhone2,
                contacts[9].PhoneNumbers[0].Key,
                166,
                @"[In t:PhoneNumberKeyType Simple Type] HomePhone2: Identifies the telephone number as a second home telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R167
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.Isdn,
                contacts[10].PhoneNumbers[0].Key,
                167,
                @"[In t:PhoneNumberKeyType Simple Type] Isdn: Identifies the telephone number as an Integrated Services Digital Network (ISDN) line.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R168
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.MobilePhone,
                contacts[11].PhoneNumbers[0].Key,
                168,
                @"[In t:PhoneNumberKeyType Simple Type] MobilePhone: Identifies the telephone number as a mobile phone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R169
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.OtherFax,
                contacts[12].PhoneNumbers[0].Key,
                169,
                @"[In t:PhoneNumberKeyType Simple Type] OtherFax: Identifies the telephone number as another fax number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R170
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.OtherTelephone,
                contacts[13].PhoneNumbers[0].Key,
                170,
                @"[In t:PhoneNumberKeyType Simple Type] OtherTelephone: Identifies the telephone number as another telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R171
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.Pager,
                contacts[14].PhoneNumbers[0].Key,
                171,
                @"[In t:PhoneNumberKeyType Simple Type] Pager: Identifies the telephone number as a pager.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R172
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.PrimaryPhone,
                contacts[15].PhoneNumbers[0].Key,
                172,
                @"[In t:PhoneNumberKeyType Simple Type] PrimaryPhone: Identifies the telephone number as the primary telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R173
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.RadioPhone,
                contacts[16].PhoneNumbers[0].Key,
                173,
                @"[In t:PhoneNumberKeyType Simple Type] RadioPhone: Identifies the telephone number as a radio telephone.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R174
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.Telex,
                contacts[17].PhoneNumbers[0].Key,
                174,
                @"[In t:PhoneNumberKeyType Simple Type] Telex: Identifies the telephone number as a telex telephone number.");

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

            // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R175
            Site.CaptureRequirementIfAreEqual<PhoneNumberKeyType>(
                PhoneNumberKeyType.TtyTddPhone,
                contacts[18].PhoneNumbers[0].Key,
                175,
                @"[In t:PhoneNumberKeyType Simple Type] TtyTddPhone: Identifies the telephone number as a teletype/telecommunication device for the deaf (TTY/TDD) telephone number.");
            #endregion
        }
 /// <summary>
 /// Factory method for creating a phone number dictionary field uri
 /// </summary>
 /// <param name="fieldIndex">Indicates the type of phone number</param>
 /// <returns>Indexed field uri</returns>
 /// 
 public static PathToIndexedFieldType CreatePhoneNumber(PhoneNumberKeyType fieldIndex)
 {
     return new PathToIndexedFieldType(DictionaryURIType.contactsPhoneNumber, fieldIndex.ToString());
 }
        private PropertyDefinition Convert(PhoneNumberKeyType type)
        {
            switch (type)
            {
            case PhoneNumberKeyType.AssistantPhone:
                return(ContactSchema.AssistantPhoneNumber);

            case PhoneNumberKeyType.BusinessFax:
                return(ContactSchema.WorkFax);

            case PhoneNumberKeyType.BusinessPhone:
                return(ContactSchema.BusinessPhoneNumber);

            case PhoneNumberKeyType.BusinessPhone2:
                return(ContactSchema.BusinessPhoneNumber2);

            case PhoneNumberKeyType.Callback:
                return(ContactSchema.CallbackPhone);

            case PhoneNumberKeyType.CarPhone:
                return(ContactSchema.CarPhone);

            case PhoneNumberKeyType.CompanyMainPhone:
                return(ContactSchema.OrganizationMainPhone);

            case PhoneNumberKeyType.HomeFax:
                return(ContactSchema.HomeFax);

            case PhoneNumberKeyType.HomePhone:
                return(ContactSchema.HomePhone);

            case PhoneNumberKeyType.HomePhone2:
                return(ContactSchema.HomePhone2);

            case PhoneNumberKeyType.Isdn:
                return(ContactSchema.InternationalIsdnNumber);

            case PhoneNumberKeyType.MobilePhone:
                return(ContactSchema.MobilePhone);

            case PhoneNumberKeyType.OtherFax:
                return(ContactSchema.OtherFax);

            case PhoneNumberKeyType.OtherTelephone:
                return(ContactSchema.OtherTelephone);

            case PhoneNumberKeyType.Pager:
                return(ContactSchema.Pager);

            case PhoneNumberKeyType.PrimaryPhone:
                return(ContactSchema.PrimaryTelephoneNumber);

            case PhoneNumberKeyType.RadioPhone:
                return(ContactSchema.RadioPhone);

            case PhoneNumberKeyType.Telex:
                return(ContactSchema.TelexNumber);

            case PhoneNumberKeyType.TtyTddPhone:
                return(ContactSchema.TtyTddPhoneNumber);

            default:
                throw new InvalidContactException();
            }
        }