Ejemplo n.º 1
0
        public void MaskFormattedInput_Where_FormatLength_is_Equal()
        {
            var input  = "12-34";
            var format = "##-##";
            var result = MonkeyEntry.Mask(input, format);

            Assert.IsNotEmpty(result);
            Assert.AreEqual("12-34", result);
        }
Ejemplo n.º 2
0
        public void MaskInput_Where_Format_is_Null()
        {
            var    input  = "1234";
            string format = null;
            var    result = MonkeyEntry.Mask(input, format);

            Assert.IsNotEmpty(result);
            Assert.AreEqual(input, result);
        }
Ejemplo n.º 3
0
        public void MaskInput_Where_InputLength_is_Greater_MaxLength()
        {
            var input  = "12345";
            var format = "##-##";
            var result = MonkeyEntry.Mask(input, format, 4);

            Assert.IsNotEmpty(result);
            Assert.AreEqual("12-34", result);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Mask the input based on the provided format.
 /// </summary>
 /// <remarks>
 /// ONLY SUPPORTS NUMERIC INPUTS AND FORMATS
 /// Intended to be used with keyboard entry.
 /// </remarks>
 /// <example>
 /// // partial mask
 /// var input = "123-4";
 /// var format = "###-####";
 /// MonkeyEntry.Mask(input, format);
 ///
 /// // full mask
 /// var input = "123-4567";
 /// var format = "###-####";
 /// MonkeyEntry.Mask(input, format);
 ///
 /// // full mask and limit a max length
 /// var input = "123-4567";
 /// var format = "###-####";
 /// MonkeyEntry.Mask(input, format, 7);
 /// </example>
 /// <param name="input">Unmasked string</param>
 /// <param name="format">Formatting pattern</param>
 /// <param name="maxLength">Max length of output</param>
 /// <returns>Masked input</returns>
 public static string EntryMask(this string input, string format, int maxLength = 0)
 {
     return(MonkeyEntry.Mask(input, format, maxLength));
 }