Ejemplo n.º 1
0
        public void TestIsValidChar_ReturnsTrueIfTextBoxNotSet()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();

            //---------------Assert pre-condition---------------
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsTrue(strategy.IsValidCharacter('a'));
            Assert.IsTrue(strategy.IsValidCharacter(' '));
            Assert.IsTrue(strategy.IsValidCharacter('.'));
            Assert.IsTrue(strategy.IsValidCharacter('-'));
            //---------------Tear down -------------------------
        }
Ejemplo n.º 2
0
        public void TestIsValidChar_WithInt_ReturnsTrueForNumber()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            BOProp boProp = CreateBOPropForType(typeof(int));

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsTrue(strategy.IsValidCharacter('0'));
            Assert.IsTrue(strategy.IsValidCharacter('9'));
            Assert.IsTrue(strategy.IsValidCharacter('-'));
            Assert.IsTrue(strategy.IsValidCharacter(Convert.ToChar(8)));
            //---------------Tear down -------------------------
        }
Ejemplo n.º 3
0
        public void TestIsValidChar_WithString_ReturnsTrueForNonNumericTypes()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            BOProp boProp = CreateBOPropForType(typeof(string));

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsTrue(strategy.IsValidCharacter('a'));
            Assert.IsTrue(strategy.IsValidCharacter(' '));
            Assert.IsTrue(strategy.IsValidCharacter('.'));
            Assert.IsTrue(strategy.IsValidCharacter('-'));
            //---------------Tear down -------------------------
        }
Ejemplo n.º 4
0
        public void TestIsValidChar_WithDecimal_ReturnsFalseForNonNumber()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            BOProp boProp = CreateBOPropForType(typeof(decimal));

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsFalse(strategy.IsValidCharacter('a'));
            Assert.IsFalse(strategy.IsValidCharacter('A'));
            Assert.IsFalse(strategy.IsValidCharacter('+'));
            Assert.IsFalse(strategy.IsValidCharacter(Convert.ToChar(7)));
            //---------------Tear down -------------------------
        }
Ejemplo n.º 5
0
        public void TestIsValidChar_WithDecimal_ReturnsFalseForMultipleDots()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            BOProp boProp = CreateBOPropForType(typeof(decimal));

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            _mapper.Control.Text = "12.3";
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsFalse(strategy.IsValidCharacter('.'));
            //---------------Tear down -------------------------
        }
Ejemplo n.º 6
0
        public void TestIsValidChar_WithDecimal_ReturnsTrueForDotNotAtStart()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            BOProp boProp = CreateBOPropForType(typeof(decimal));

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            _mapper.Control.Text = "123";
            ((TextBoxWin)_mapper.Control).SelectionStart = 3;
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsTrue(strategy.IsValidCharacter('.'));
            //---------------Tear down -------------------------
        }
Ejemplo n.º 7
0
        public void TestIsValidChar_WithInt_ReturnsFalseForNegativeAfterStart()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            BOProp boProp = CreateBOPropForType(typeof(int));

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            _mapper.Control.Text = "123";
            ((TextBoxWin)_mapper.Control).SelectionStart = 2;
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsFalse(strategy.IsValidCharacter('-'));
            //---------------Tear down -------------------------
        }
Ejemplo n.º 8
0
        public void TestIsValidChar_WithDecimal_AddsZeroForDotAtStart()
        {
            //---------------Set up test pack-------------------
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            BOProp boProp = CreateBOPropForType(typeof(decimal));

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            _mapper.Control.Text = "";
            TextBoxWin textBox = ((TextBoxWin)_mapper.Control);

            textBox.SelectionStart = 0;
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.IsFalse(strategy.IsValidCharacter('.'));
            Assert.AreEqual("0.", textBox.Text);
            Assert.AreEqual(2, textBox.SelectionStart);
            Assert.AreEqual(0, textBox.SelectionLength);
            //---------------Tear down -------------------------
        }