public void InvalidListPathShouldThrow() { const string InvalidAttribute = "capacity_reservation_specification.capacity_reservation_preference"; var expectedMessage = $"Invalid path \"{InvalidAttribute}\": Attribute at \"{InvalidAttribute.Split('.').First()}\" is a set or a list. List indicator ('*', '#' or integer) was expected next in path."; Action action = () => this.fixture.Ec2Instance.GetAttributeByPath( "capacity_reservation_specification.capacity_reservation_preference"); action.Should().Throw <InvalidOperationException>().WithMessage(expectedMessage); }
/// <summary> /// Get the next list of attributes to compare to each other. /// If an attribute is not present, a null pointer is returned in the AttributeCollection. /// If all attributes have been compared, null is returned. /// </summary> /// <returns>The attributes to compare.</returns> public AttributeList GetNextAttributes() { AttributeList nextAttributes = null; if (this.compareRulesIndex >= this.compareRules.Count) { nextAttributes = null; } else { nextAttributes = new AttributeList(); CompareRule compareRule = this.compareRules[this.compareRulesIndex] as CompareRule; nextAttributes.CompareRule = compareRule; // Use the attributeCollectionsIndex to iterate through both the attributeCollections and compareRule. for (int validationRuleListIndex = 0; validationRuleListIndex < compareRule.Count; validationRuleListIndex++) { ValidationRuleBase validationRule = compareRule[validationRuleListIndex]; if (validationRule is ValidationRuleDicomAttribute) { ValidationRuleDicomAttribute validationRuleDicomAttribute = validationRule as ValidationRuleDicomAttribute; DicomAttributeCollection dicomAttributeCollection = this.attributeCollections[validationRuleListIndex] as DicomAttributeCollection; DicomAttribute dicomAttribute = null; if (validationRuleDicomAttribute == null) // If nothing needs to be validated. { dicomAttribute = null; } else { DvtkHighLevelInterface.Dicom.Other.Attribute dicomAttributeOnly = null; if (dicomAttributeCollection.AttributeSetOnly.Exists(validationRuleDicomAttribute.TagSequenceString)) { dicomAttributeOnly = dicomAttributeCollection.AttributeSetOnly[validationRuleDicomAttribute.TagSequenceString]; } else { dicomAttributeOnly = new InvalidAttribute(); } // Merge the validation flags from the validation rule and the attribute collection. ValidationRuleDicomAttribute mergedValidationRuleDicomAttribute = new ValidationRuleDicomAttribute(validationRuleDicomAttribute.TagSequenceString, validationRuleDicomAttribute.Flags | dicomAttributeCollection.Flags); dicomAttribute = new DicomAttribute(dicomAttributeOnly, mergedValidationRuleDicomAttribute); dicomAttribute.DisplayFullTagSequence = true; } nextAttributes.Add(dicomAttribute); } else if (validationRule is ValidationRuleHl7Attribute) { ValidationRuleHl7Attribute validationRuleHl7Attribute = validationRule as ValidationRuleHl7Attribute; Hl7AttributeCollection hl7AttributeCollection = this.attributeCollections[validationRuleListIndex] as Hl7AttributeCollection; Hl7Attribute hl7Attribute = null; if (validationRuleHl7Attribute == null) // If nothing needs to be validated. { hl7Attribute = null; } else { // Merge the validation flags from the validation rule and the attribute collection. ValidationRuleHl7Attribute mergedValidationRuleHl7Attribute = new ValidationRuleHl7Attribute(validationRuleHl7Attribute.Hl7Tag, validationRuleHl7Attribute.Flags | hl7AttributeCollection.Flags); hl7Attribute = new Hl7Attribute(hl7AttributeCollection.Hl7MessageOnly.Value(validationRuleHl7Attribute.Hl7Tag), mergedValidationRuleHl7Attribute); } nextAttributes.Add(hl7Attribute); } else { nextAttributes.Add(null); } } this.compareRulesIndex++; } return(nextAttributes); }