コード例 #1
0
        public void GivenMultiValuesException_WhenGetMessage_ShouldReturnExpected()
        {
            var name      = "tagname";
            var vr        = DicomVR.DA;
            var exception = ElementValidationExceptionFactory.CreateMultiValuesException(name, vr);

            Assert.Equal($"Dicom element '{name}' failed validation for VR '{vr}': Dicom element has multiple values. Indexing is only supported on single value element.", exception.Message);
        }
コード例 #2
0
        public virtual void Validate(DicomElement dicomElement)
        {
            EnsureArg.IsNotNull(dicomElement, nameof(dicomElement));
            DicomVR vr = dicomElement.ValueRepresentation;

            if (ExtendedQueryTagEntryValidator.SupportedVRCodes.Contains(vr.Code))
            {
                // only works for single value dicom element ( Since we accept empty/null value, Count = 0 is accepted).
                if (dicomElement.Count > 1)
                {
                    throw ElementValidationExceptionFactory.CreateMultiValuesException(dicomElement.Tag.GetFriendlyName(), vr);
                }
            }
            else
            {
                Debug.Fail($"Validating VR {vr.Code} is not supported.");
            }
        }