Beispiel #1
0
        public void InputFieldBufferTests()
        {
            WindowManager manager      = new WindowManager(ConsoleColor.White, ConsoleColor.Red);
            InputField    letterBuffer = manager.CreateInputField(TESTBUFFER, new CursorPosition(20, 20), 20, InputType.StringNoNumbersNoSpecialCharacters, false);

            letterBuffer.SetBuffer("abcdefghiljklmnopqrs");
            Assert.True(letterBuffer.ValidateField());
            Assert.Greater(letterBuffer.BufferLength, 10);
            letterBuffer.AddCharToBuffer('t');
            Assert.True(letterBuffer.ValidateField());
            letterBuffer.EmptyBuffer(false);
            Assert.False(letterBuffer.ValidateField());
            letterBuffer.SetBuffer("abcde");
            Assert.AreEqual(5, letterBuffer.BufferLength);
            Assert.True(letterBuffer.DeleteChar());
            Assert.AreEqual(4, letterBuffer.BufferLength);
            Assert.True(letterBuffer.ValidateField());
            letterBuffer.AddCharToBuffer('l');
            Assert.AreEqual(5, letterBuffer.BufferLength);
            Assert.True(letterBuffer.DeleteChar());
        }
Beispiel #2
0
        public void InputFieldValidationOnlyIntegerAndNull()
        {
            int           temp;
            WindowManager manager      = new WindowManager(ConsoleColor.White, ConsoleColor.Red);
            InputField    fieldOnlyInt = manager.CreateInputField(TESTINT, new CursorPosition(10, 10), 10, InputType.Integer, true);

            Assert.True(fieldOnlyInt.ValidateField());
            Assert.IsEmpty(fieldOnlyInt.BufferText);
            Assert.AreEqual(10, fieldOnlyInt.Maxchars);
            fieldOnlyInt.SetBuffer("123123123");
            Assert.GreaterOrEqual(fieldOnlyInt.BufferLength, 9);
            Assert.True(Int32.TryParse(fieldOnlyInt.BufferText, out temp));
            Assert.True(fieldOnlyInt.ValidateField());
            fieldOnlyInt.AddCharToBuffer('c');
            Assert.False(fieldOnlyInt.ValidateField());
            Assert.False(Int32.TryParse(fieldOnlyInt.BufferText, out temp));
            Assert.True(fieldOnlyInt.DeleteChar());
            Assert.True(fieldOnlyInt.ValidateField());
            fieldOnlyInt.SetBuffer("-10");
            Assert.True(fieldOnlyInt.ValidateField());
        }