public void MSOXWSCONT_S01_TC08_VerifyContactItemWithPhysicalAddressKeyTypeEnums() { // The value count of enumeration "PhysicalAddressKeyType" is 3. int enumCount = 3; PhysicalAddressKeyType[] physicalAddressKeyTypes = new PhysicalAddressKeyType[enumCount]; physicalAddressKeyTypes[0] = PhysicalAddressKeyType.Business; physicalAddressKeyTypes[1] = PhysicalAddressKeyType.Home; physicalAddressKeyTypes[2] = PhysicalAddressKeyType.Other; // Define a contact array to store the contact items got from GetItem operation response. // Each contact should contain a PhysicalAddressKeyType value as its element's value. ContactItemType[] contacts = new ContactItemType[enumCount]; for (int i = 0; i < enumCount; i++) { PhysicalAddressKeyType physicalAddressKeyType = physicalAddressKeyTypes[i]; #region Step 1:Create the contact item with PhysicalAddressKeyType // Create a contact item with PhysicalAddressKeyType. ContactItemType item = this.BuildContactItemWithPhysicalAddress(physicalAddressKeyType); 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].PhysicalAddresses, "The PhysicalAddresses element in returned contact item should not be null."); Site.Assert.AreEqual<int>( 1, contacts[i].PhysicalAddresses.GetLength(0), "One entry of PhysicalAddresses 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_R187"); // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R187 Site.CaptureRequirementIfAreEqual<PhysicalAddressKeyType>( PhysicalAddressKeyType.Business, contacts[0].PhysicalAddresses[0].Key, 187, @"[In t:PhysicalAddressKeyType Simple Type] Business: Identifies the address as a business address."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCONT_R188"); // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R188 Site.CaptureRequirementIfAreEqual<PhysicalAddressKeyType>( PhysicalAddressKeyType.Home, contacts[1].PhysicalAddresses[0].Key, 188, @"[In t:PhysicalAddressKeyType Simple Type] Home: Identifies the address as a home address."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCONT_R189"); // Verify MS-OXWSCONT requirement: MS-OXWSCONT_R189 Site.CaptureRequirementIfAreEqual<PhysicalAddressKeyType>( PhysicalAddressKeyType.Other, contacts[2].PhysicalAddresses[0].Key, 189, @"[In t:PhysicalAddressKeyType Simple Type] Other: Identifies the address as an address of type other."); #endregion }
/// <summary> /// Factory method for creating a physical address part field uri /// </summary> /// <param name="part">Indicates which part of a physical address to use</param> /// <param name="fieldIndex">Indicates the address category (home, business, etc...)</param> /// <returns>Indexed field uri</returns> /// public static PathToIndexedFieldType CreatePhysicalAddress(PhysicalAddressPart part, PhysicalAddressKeyType fieldIndex) { // Since we defined our enum to have the same values as the corresponding dictionary uris, // we can just cast our enum value here. // return new PathToIndexedFieldType((DictionaryURIType)part, fieldIndex.ToString()); }
/// <summary> /// Build a contact item with enumeration value of PhysicalAddressKeyType. /// </summary> /// <param name="physicalAddressKeyType">The enumeration value of PhysicalAddressKeyType.</param> /// <returns>The contact item object.</returns> protected ContactItemType BuildContactItemWithPhysicalAddress(PhysicalAddressKeyType physicalAddressKeyType) { // Create a contact item type. ContactItemType item = new ContactItemType() { // Set a single contact physical address. PhysicalAddresses = new PhysicalAddressDictionaryEntryType[] { new PhysicalAddressDictionaryEntryType() { City = Common.GenerateResourceName( this.Site, "City"), Key = physicalAddressKeyType, } } }; return item; }
public static PhysicalAddressDictionaryEntryType GetValueByType(PhysicalAddressDictionaryEntryType[] types, PhysicalAddressKeyType key, bool checkEmpty = false) { if (types != null) { foreach (PhysicalAddressDictionaryEntryType item in types) { if (item.Key == key) { return(item); } } } if (checkEmpty) { throw new PXException("Email with type {0} has not found.", key.ToString()); } return(null); }
public static PhysicalAddressDictionaryEntryType GetValueByType(PhysicalAddressDictionaryEntryType[] types, PhysicalAddressKeyType key, bool checkEmpty = false) { if (types != null) { foreach (PhysicalAddressDictionaryEntryType item in types) { if (item.Key == key) { return(item); } } } if (checkEmpty) { throw new PXException(PXMessages.LocalizeFormatNoPrefix(Messages.EmailTypeNotFound, key.ToString())); } return(null); }