/// <summary> /// A method used to verify the relationship between CHOICES and MAPPINGS elements. If the CHOICES element present, the protocol SUT should provide a MAPPINGS element. Each CHOICE element should found a mapped MAPPING item. /// </summary> /// <param name="fieldDefinition">A parameter represents the FieldDefinition instance which contains the CHOICES and MAPPINGS elements.</param> /// <returns>Return 'true' indicating the relationship validation pass.</returns> private bool VerifyChoicesAndMappingsRelationShip(FieldDefinition fieldDefinition) { if (null == fieldDefinition.MAPPINGS) { throw new ArgumentException("The fieldDfinition should contain valid MAPPINGDEFINITION[] type instance.", string.Empty); } if (null == fieldDefinition.CHOICES) { throw new ArgumentException("The fieldDfinition should contain valid MAPPINGDEFINITION[] type instance."); } if (0 == fieldDefinition.MAPPINGS.Length || 0 == fieldDefinition.CHOICES.Length) { // If the MAPPINGS and CHOICES element does not contain any item, it is match the TD. return true; } if (fieldDefinition.MAPPINGS.Length != fieldDefinition.CHOICES.Length) { this.Site.Assert.Fail("The MAPPING items' number should equal to the CHOICE items' number."); } bool isMappingItemsMatchChoicesItems = false; foreach (CHOICEDEFINITION choiceItem in fieldDefinition.CHOICES) { string choiceItemValue = choiceItem.Text[0]; // The choice item Value should be found in MAPPINGS array. isMappingItemsMatchChoicesItems = fieldDefinition.MAPPINGS.Any(Founder => Founder.Value1.Equals(choiceItemValue, StringComparison.OrdinalIgnoreCase)); if (!isMappingItemsMatchChoicesItems) { break; } } return isMappingItemsMatchChoicesItems; }