예제 #1
0
 public static void Validate(string value, int maxLength, string name, DicomVR vr)
 {
     EnsureArg.IsNotNullOrEmpty(name, nameof(name));
     EnsureArg.IsNotNull(vr, nameof(vr));
     if (value?.Length > maxLength)
     {
         throw ElementValidationExceptionFactory.CreateExceedMaxLengthException(name, vr, value, maxLength);
     }
 }
        public void GivenExceedMaxLengthException_WhenGetMessage_ShouldReturnExpected()
        {
            var name      = "tagname";
            var value     = "tagvalue";
            var vr        = DicomVR.DA;
            int maxLength = 8;
            var exception = ElementValidationExceptionFactory.CreateExceedMaxLengthException(name, vr, value, maxLength);

            Assert.Equal($"Dicom element '{name}' with value '{value}' failed validation for VR '{vr}': Value length exceeds maximum length of {maxLength}.", exception.Message);
        }