Example #1
0
        public void ReturnsTrueOnControlCharacterInput()
        {
            var isValid = TriangleChecker.IsValidKeystroke("", (char)0x0000);

            isValid &= TriangleChecker.IsValidKeystroke("", (char)0x001F);
            isValid &= TriangleChecker.IsValidKeystroke("", (char)0x007F);
            isValid &= TriangleChecker.IsValidKeystroke("", (char)0x0080);
            isValid &= TriangleChecker.IsValidKeystroke("", (char)0x009F);

            Assert.IsTrue(isValid);
        }
Example #2
0
        public void ReturnsFalseOnInvalidCharacterInput()
        {
            var isValid = TriangleChecker.IsValidKeystroke("", 'a');

            isValid |= TriangleChecker.IsValidKeystroke("", 'B');
            isValid |= TriangleChecker.IsValidKeystroke("", '!');
            isValid |= TriangleChecker.IsValidKeystroke("", '*');
            isValid |= TriangleChecker.IsValidKeystroke("", '-');
            isValid |= TriangleChecker.IsValidKeystroke("", '+');
            isValid |= TriangleChecker.IsValidKeystroke("", ' ');

            Assert.IsFalse(isValid);
        }
Example #3
0
        public void ReturnsTrueOnNumericalInput()
        {
            var isValid = TriangleChecker.IsValidKeystroke("", '0');

            isValid &= TriangleChecker.IsValidKeystroke("", '1');
            isValid &= TriangleChecker.IsValidKeystroke("", '2');
            isValid &= TriangleChecker.IsValidKeystroke("", '3');
            isValid &= TriangleChecker.IsValidKeystroke("", '4');
            isValid &= TriangleChecker.IsValidKeystroke("", '5');
            isValid &= TriangleChecker.IsValidKeystroke("", '6');
            isValid &= TriangleChecker.IsValidKeystroke("", '7');
            isValid &= TriangleChecker.IsValidKeystroke("", '8');
            isValid &= TriangleChecker.IsValidKeystroke("", '9');

            Assert.IsTrue(isValid);
        }
Example #4
0
        public void ReturnsFalseOnFirstPeriod()
        {
            var isValid = TriangleChecker.IsValidKeystroke("0.1", '.');

            Assert.IsFalse(isValid);
        }
Example #5
0
 public void ThrowsExceptionOnNullString()
 {
     Assert.ThrowsException <ArgumentException>(() => TriangleChecker.IsValidKeystroke(null, '1'));
 }