Example #1
0
        public void Wpf_GettingPropertyValueByIdWithoutPatternInterfaceWorks()
        {
            CaretPositionPattern.Initialize();
            WSetTextAndSelection("abcd", 1, 2);
            var selStart = _wAdvancedTextBoxElement.GetCurrentPropertyValue(CaretPositionPattern.SelectionStartProperty);

            Assert.AreEqual(1, selStart);
        }
Example #2
0
        public void Wpf_CaretPositionPatternSmokeTest()
        {
            CaretPositionPattern.Initialize();
            var cps = (ICaretPositionPattern)_wAdvancedTextBoxElement.GetCurrentPattern(CaretPositionPattern.Pattern);

            Assert.IsNotNull(cps);

            // sanity check: intial selection is none, there's no text after all
            Assert.AreEqual(0, cps.CurrentSelectionStart);
            Assert.AreEqual(0, cps.CurrentSelectionLength);

            // enter "abcd" and select central part of it - "bc"
            WSetTextAndSelection("abcd", 1, 2);
            Assert.AreEqual(1, cps.CurrentSelectionStart);
            Assert.AreEqual(2, cps.CurrentSelectionLength);

            // validate that selected text retrieved from TextPattern changed as expected
            var text           = (TextPattern)_wAdvancedTextBoxElement.GetCurrentPattern(TextPattern.Pattern);
            var selectionArray = text.GetSelection();
            var selection      = selectionArray[0];
            var selectedString = selection.GetText(-1);

            Assert.AreEqual("bc", selectedString);
        }