Ejemplo n.º 1
0
        public void CharsAreUnique_InputCharsAreNotUnique_ReturnsFalse(string input)
        {
            // Arrange / Act
            var actual = SupportClass.CharsAreUnique(input);

            // Assert
            Assert.IsFalse(actual);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates new EncodingCharacters object with the given character
        /// values. If the encodingCharacters argument is null, the default
        /// values are used.
        /// </summary>
        /// <param name="fieldSeparator">The field separator.</param>
        /// <param name="encodingCharacters">
        /// Consists of the characters that appear in
        /// MSH-2 (see section 2.8 of the HL7 spec). The characters are
        /// Component Separator, Repetition Separator, Escape Character, and
        /// Subcomponent Separator (in that order).
        /// </param>
        /// <exception cref="HL7Exception">If encoding characters are not unique.</exception>
        public EncodingCharacters(char fieldSeparator, string encodingCharacters)
        {
            if (char.IsWhiteSpace(fieldSeparator) || fieldSeparator == char.MinValue)
            {
                throw new HL7Exception("Field Seperator must be a printable character.");
            }

            FieldSeparator = fieldSeparator;

            encChars = new char[4];
#if NET35
            if (string.IsNullOrEmpty(encodingCharacters) || encodingCharacters.Trim().Length == 0)
#else
            if (string.IsNullOrWhiteSpace(encodingCharacters))
#endif
            {
                encChars[0] = '^';

                encChars[1] = '~';

                encChars[2] = '\\';

                encChars[3] = '&';
            }
            else
            {
                if (encodingCharacters.Any(@char => char.IsWhiteSpace(@char) || @char == char.MinValue))
                {
                    throw new HL7Exception("Encoding characters must be printable characters.");
                }

                if (!SupportClass.CharsAreUnique(encodingCharacters))
                {
                    throw new HL7Exception("Encoding characters must be unique.");
                }

                SupportClass.GetCharsFromString(encodingCharacters, 0, 4, encChars, 0);
            }
        }
Ejemplo n.º 3
0
 public void CharsAreUnique_InputIsNullOrEmpty_ThrowsArgumentException(string input)
 {
     // Arrange / Act / Assert
     Assert.Throws <ArgumentException>(
         () => SupportClass.CharsAreUnique(input));
 }