Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds to para BLDR.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal override void AddToParaBldr(StTxtParaBldr bldr, int ws, FwStyleSheet styleSheet)
        {
            if (string.IsNullOrEmpty(Href))
            {
                throw new Exception("OXESA validation found an invalid URL.");
            }

            bool fSucceeded = EditingHelper.AddHyperlink(bldr.StringBuilder,
                                                         ws, Text, Href, styleSheet);

            Debug.Assert(fSucceeded);
        }
Example #2
0
        public void AddHyperlink()
        {
            ITsStrBldr  strBldr        = TsStrBldrClass.Create();
            DynamicMock mockStylesheet = new DynamicMock(typeof(FwStyleSheet));

            mockStylesheet.Strict = true;
            DynamicMock mockHyperlinkStyle = new DynamicMock(typeof(StStyle));

            mockHyperlinkStyle.Strict = true;
            mockHyperlinkStyle.Expect("InUse", true);
            mockStylesheet.ExpectAndReturn("FindStyle", (IStStyle)mockHyperlinkStyle.MockInstance, StStyle.Hyperlink);
            FwStyleSheet styleSheet = (FwStyleSheet)mockStylesheet.MockInstance;

            Assert.IsTrue(EditingHelper.AddHyperlink(strBldr, Cache.DefaultAnalWs, "Click Here",
                                                     "www.google.com", styleSheet));
            Assert.AreEqual(1, strBldr.RunCount);
            Assert.AreEqual("Click Here", strBldr.get_RunText(0));
            ITsTextProps props = strBldr.get_Properties(0);

            StStyleTests.AssertHyperlinkPropsAreCorrect(props, Cache.DefaultAnalWs, "www.google.com");
            mockHyperlinkStyle.Verify();
            mockStylesheet.Verify();
        }