Exemplo n.º 1
0
        public void AddSpacesToSpecialTags()
        {
            string s1 = "<p>List:</p><ol><li>Peter</li></ol>";
            string s2 = "<p>List:</p><ol><li>Peter</li></ol>";

            var    _helper  = new DMPCWMTHelper();
            string expected = " <p>List:</p>  <ol> <li> Peter </li> </ol> ";
            string actual   = _helper.PrettyDiffFormatter(s1, s2);

            Assert.AreEqual(expected, actual);

            s1       = "<p>List:</p><ol><li>Peter</li></ol>";
            s2       = "<p>Listy:</p><ol><li>Pepper</li></ol>";
            _helper  = new DMPCWMTHelper();
            expected = " <font style=\"background:#ffa0a0; text-decoration: line-through\"><p><font style=\"" +
                       "background:#ffa0a0; text-decoration: line-through\">List:</p> </font><font style=\"" +
                       "background:#a0ffa0\"><p><font style=\"background:#a0ffa0\">Listy:</p> </font> <ol> <li> <font style=" +
                       "\"background:#ffa0a0; text-decoration: line-through\">Peter </font><font style=" +
                       "\"background:#a0ffa0\">Pepper </font></li> </ol> ";
            actual = _helper.PrettyDiffFormatter(s1, s2);
            Assert.AreEqual(expected, actual);

            s1       = "<p>List:</p><ul><li>Peter</li></ul>";
            s2       = "<p>Listy:</p><ul><li>Pepper</li></ul>";
            _helper  = new DMPCWMTHelper();
            expected = " <font style=\"background:#ffa0a0; text-decoration: line-through\"><p><font style=\"" +
                       "background:#ffa0a0; text-decoration: line-through\">List:</p> </font><font style=\"background:" +
                       "#a0ffa0\"><p><font style=\"background:#a0ffa0\">Listy:</p> </font> <ul> <li> <font style=\"" +
                       "background:#ffa0a0; text-decoration: line-through\">Peter </font><font style=\"background:#a0ffa0\">" +
                       "Pepper </font></li> </ul> ";
            actual = _helper.PrettyDiffFormatter(s1, s2);
            Assert.AreEqual(expected, actual);

            s1      = "<p>Pepper piper <i>picked a of <strong>pickled peppers and</strong></i> went home.</p> ";
            s2      = "<p>Peter parker <i>picked a peck of <strong>pickled</strong> peppers and came</i> home.</p> ";
            _helper = new DMPCWMTHelper();
            actual  = _helper.PrettyDiffFormatter(s1, s2);
            Assert.AreEqual("", "");
        }
Exemplo n.º 2
0
        public void PrettyDiffFormatter()
        {
            string s1 = "<p>Peter piper picked a peck of.</p>";
            string s2 = "<p>Peter parker penned a peck of.</p>";

            _helper = new DMPCWMTHelper();
            string expected = " <p>Peter <font style=\"background:#ffa0a0; text-decoration: line-through\">piper picked" +
                              " </font><font style=\"background:#a0ffa0\">parker penned </font>a peck of.</p> ";
            string actual = _helper.PrettyDiffFormatter(s1, s2);

            Assert.AreEqual(expected, actual);

            _helper  = new DMPCWMTHelper();
            expected = " <p>Peter <font style=\"background:#ffa0a0; text-decoration: line-through\"" +
                       ">piper picked </font><font style=\"background:#a0ffa0\"" +
                       ">parker penned </font>a peck of.</p> ";
            actual = _helper.PrettyDiffFormatter(s1, s2);
            Assert.AreEqual(expected, actual);

            s1 = "<p>These are the teachin<i>g notes for the Box Proble</i>m. Huh? Do we have it now.</p>" +
                 "<ol><li>go geoducks!</li><li>Two</li><li> Three sode</li></ol> ";
            s2       = "<p>This is the master narrative for Box Problem</p>";
            _helper  = new DMPCWMTHelper();
            expected = " <font style=\"background:#ffa0a0; text-decoration: line-through\"><p><font style=\"background:" +
                       "#ffa0a0; text-decoration: line-through\">These are </font><font style=\"background:#a0ffa0\">This is " +
                       "</font>the <font style=\"background:#ffa0a0; text-decoration: line-through\">teachin<i>g notes </i>" +
                       "</font><font style=\"background:#ffa0a0; text-decoration: line-through\"><i>for </i></font><font style=" +
                       "\"background:#ffa0a0; text-decoration: line-through\"><i>the </i></font><font style=\"background:" +
                       "#ffa0a0; text-decoration: line-through\"><i>Box </i></font><font style=\"background:#ffa0a0; " +
                       "text-decoration: line-through\"><i>Proble</i>m. Huh? Do we have it now.   </font><li><font style=" +
                       "\"background:#ffa0a0; text-decoration: line-through\"> go geoducks! </li></font><li><font style=" +
                       "\"background:#ffa0a0; text-decoration: line-through\"> Two </li></font><li><font style=\"" +
                       "background:#ffa0a0; text-decoration: line-through\">  Three sode </li>   </font><font style=\"" +
                       "background:#a0ffa0\">master narrative </font><font style=\"background:#a0ffa0\">for </font>" +
                       "<font style=\"background:#a0ffa0\">Box </font><font style=\"background:#a0ffa0\">Problem</p> </font>";
            actual = _helper.PrettyDiffFormatter(s1, s2);
            Assert.AreEqual(expected, actual);

            _helper  = new DMPCWMTHelper();
            s1       = "<p>Test <b>sentence a</b>";
            s2       = "<p>Test <b>sentence b</b>";
            expected = " <p>Test <b>sentence <font style=\"background:#ffa0a0; text-decoration: line-through\">a</b>" +
                       "</font><font style=\"background:#a0ffa0\"><b>b</b></font>";
            actual = _helper.PrettyDiffFormatter(s1, s2);
            Assert.AreEqual(expected, actual);

            //This tests the split diff concatenator by having inses and dels that need to be added to the list
            s1        = "<p>Pepper piper <i>picked a peck of <strong>pickled peppers and</strong></i> went home.</p>";
            s2        = "<p>Peter parker <i>picked a peck of <strong>pickled</strong> peppers and came</i> home.</p>";
            _helper   = new DMPCWMTHelper();
            _finished = _helper.PrettyDiffFormatter(s1, s2);
            expected  = " <font style=\"background:#ffa0a0; text-decoration: line-through\"><p><font style=\"" +
                        "background:#ffa0a0; text-decoration: line-through\">Pepper piper </font><font style=\"background:" +
                        "#a0ffa0\">Peter parker </font><i>picked a peck of <font style=\"background:#ffa0a0; " +
                        "text-decoration: line-through\"><strong>pickled </strong></font><font style=\"background:#ffa0a0; " +
                        "text-decoration: line-through\"><strong>peppers </strong></font><font style=\"background:#ffa0a0;" +
                        " text-decoration: line-through\"><strong>and</strong></i> went </font><font style=\"" +
                        "background:#a0ffa0\"><strong>pickled</strong> </font><font style=\"background:#a0ffa0\">peppers " +
                        "</font><font style=\"background:#a0ffa0\"><i>and came</i> </font>home.</p> ";
            Assert.AreEqual(expected, _finished);

            //Trying to cover other branch in OtherList method
            s1 = "<i>The test sentence a</i>";
            s2 = "<i>The test </i>sentence<i> a</i>";

            _helper  = new DMPCWMTHelper();
            expected = "<i>The test <font style=\"background:#ffa0a0; text-decoration: line-through\">sentence </font>" +
                       "<font style=\"background:#ffa0a0; text-decoration: line-through\"><i>a</i></font>" +
                       "<font style=\"background:#a0ffa0\"></i>sentence<i> </i></font>" +
                       "<font style=\"background:#a0ffa0\"><i>a</i></font>";
            actual = _helper.PrettyDiffFormatter(s1, s2);
            Assert.AreEqual(expected, actual);
        }