예제 #1
0
        public void TextPattern2Test()
        {
            // Get the  pattern
            TextPattern2 pattern = (TextPattern2)mockObject.GetCurrentPattern(TextPattern2.Pattern);

            // Test it
            System.Windows.Automation.Text.TextPatternRange annotationRange;
            try
            {
                annotationRange = pattern.RangeFromAnnotation(null);
                Assert.Fail("Expected ArgumentNullException");
            }
            catch (ArgumentNullException)
            {
            }
            catch (Exception)
            {
                Assert.Fail("Expected ArgumentNullException");
            }
            annotationRange = pattern.RangeFromAnnotation(this.mockObject);
            Assert.IsNotNull(annotationRange);
            Assert.AreEqual("fromAnnotation", annotationRange.GetText(-1));
            bool isActive;

            System.Windows.Automation.Text.TextPatternRange caretRange;
            caretRange = pattern.GetCaretRange(out isActive);
            Assert.AreEqual(true, isActive);
            Assert.IsNotNull(caretRange);
            Assert.AreEqual("caret", caretRange.GetText(-1));
        }
        /// <summary>
        /// Constructor
        /// take both of TextPattern and TextPattern2
        /// </summary>
        /// <param name="tp"></param>
        /// <param name="tp2"></param>
        public TextPatternExplorerDialog(TextPattern tp, TextPattern2 tp2)
        {
            InitializeComponent();

            this.TextPattern        = tp;
            this.TextPattern2       = tp2;
            this.cbiCaret.IsEnabled = tp2 != null;
            this.CustomList         = new List <TextRangeViewModel>();
            cbRanges.SelectedIndex  = 0;
        }