Exemplo n.º 1
0
        public void ListItemProcessing()
        {
            string s1 = "<ul> <li> test item 1 </li> </ul>";
            string s2 = "<ul> <li> test item 2 </li> </ul>";

            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            List <Diff> listDiff = _dmp.diff_wordMode(s1, s2);

            _helper.DefineStyleDupDict("", "");
            _helper.ReplaceStyledTags(listDiff[0]);
            Assert.IsEmpty(_helper.EqualStyleList);

            _helper.ReplaceStyledTags(listDiff[1]);
            _helper.ReplaceStyledTags(listDiff[2]);
            Assert.DoesNotThrow(() => _helper.ReplaceStyledTags(listDiff[3]));
        }
Exemplo n.º 2
0
        public void ActiveTagEquality()
        {
            string s1 = "<p>Pepper piper <i>picked a peck of <strong>pickled peppers and</strong></i> went home.</p>";
            string s2 = "<p>Peter parker <i>picked a peck of <strong>pickled</strong> peppers and</i> came home.</p>";

            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            List <Diff> diffList = _dmp.diff_wordMode(s1, s2);

            _helper.DefineStyleDupDict("background:#069edb", "background:#ffa0a0; text-decoration: line-through");

            _helper.ReplaceStyledTags(diffList.ElementAt(0));
            _helper.ReplaceStyledTags(diffList.ElementAt(3));
            Assert.Contains(new Tuple <char, char>((char)0xE002, (char)0xE003), _helper.DelStyleList);
            Assert.IsTrue(!_helper.ActiveTagEquality());

            _helper.ReplaceStyledTags(diffList.ElementAt(1));
            _helper.ReplaceStyledTags(diffList.ElementAt(2));
            _helper.ReplaceStyledTags(diffList.ElementAt(4));
            Assert.IsTrue(!_helper.ActiveTagEquality());
        }
Exemplo n.º 3
0
        public void TagsWithoutClosersDontEndUpInList()
        {
            string s1 = "<test/ >";
            string s2 = "<test/ >";

            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            _helper.DefineStyleDupDict("ins", "del");
            List <Diff> diffList = _dmp.diff_wordMode(s1, s2);

            _helper.ReplaceStyledTags(diffList[0]);
            Assert.IsEmpty(_helper.EqualStyleList);
            Assert.IsEmpty(_helper.DelStyleList);
            Assert.IsEmpty(_helper.InsStyleList);
        }
Exemplo n.º 4
0
        public void ProcessBlockCloser()
        {
            string s1 = "<p>The girl went to the store.</p>";
            string s2 = "<p>She went to the store</p>";

            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            List <Diff> diffList = _dmp.diff_wordMode(s1, s2);

            _helper.DefineStyleDupDict("background:#069edb", "background:#ffa0a0; text-decoration: line-through");

            _helper.ReplaceStyledTags(diffList.First());
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\">" +
                            "<p><font style=\"background:#ffa0a0; text-decoration: line-through\">The girl </font>",
                            diffList.First().text);

            _helper.ReplaceStyledTags(diffList.ElementAt(1));
            Assert.AreEqual("<font style=\"background:#069edb\">She </font>", diffList.ElementAt(1).text);

            _helper.ReplaceStyledTags(diffList.ElementAt(2));
            Assert.AreEqual("went to the ", diffList.ElementAt(2).text);

            _helper.ReplaceStyledTags(diffList.ElementAt(3));
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\">store." +
                            "</font>", diffList.ElementAt(3).text);

            _helper.ReplaceStyledTags(diffList.Last());
            Assert.AreEqual("<font style=\"background:#069edb\">store</p></font>", diffList.Last().text);

            s1      = "<p>She went to the store.</p>";
            s2      = "<p>She went to the store</p>";
            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            diffList = _dmp.diff_wordMode(s1, s2);
            _helper.DefineStyleDupDict("background:#069edb", "background:#ffa0a0; text-decoration: line-through");
            _helper.ReplaceStyledTags(diffList.First());
            Assert.AreEqual("<p>She went to the ", diffList.First().text);

            _helper.ReplaceStyledTags(diffList.ElementAt(1));
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\">store." +
                            "</font>", diffList.ElementAt(1).text);

            _helper.ReplaceStyledTags(diffList.Last());
            Assert.AreEqual("<font style=\"background:#069edb\">store</p></font>", diffList.Last().text);

            s1      = "<p>She went to the store. Then went home.</p>";
            s2      = "<p>She went to the store.</p> <p>Then went home.</p>";
            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            diffList = _dmp.diff_wordMode(s1, s2);
            _helper.DefineStyleDupDict("background:#069edb", "background:#ffa0a0; text-decoration: line-through");

            _helper.ReplaceStyledTags(diffList.First());
            Assert.AreEqual("<p>She went to the ", diffList.First().text);

            _helper.ReplaceStyledTags(diffList.ElementAt(1));
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\">store. Then " +
                            "</font>", diffList.ElementAt(1).text);

            _helper.ReplaceStyledTags(diffList.ElementAt(2));
            Assert.AreEqual("<font style=\"background:#069edb\">store.</p> " +
                            "<p><font style=\"background:#069edb\">Then </font>",
                            diffList.ElementAt(2).text);

            _helper.ReplaceStyledTags(diffList.Last());
            Assert.AreEqual("went home.</p>", diffList.Last().text);

            s1      = "<p>Test</p><p>She went to the store.</p>";
            s2      = "<p>She went to the store.</p>";
            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            diffList = _dmp.diff_wordMode(s1, s2);
            _helper.DefineStyleDupDict("background:#069edb", "background:#ffa0a0; text-decoration: line-through");

            _helper.ReplaceStyledTags(diffList.First());
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\"><p>" +
                            "<font style=\"background:#ffa0a0; text-decoration: line-through\">Test</p><p>" +
                            "<font style=\"background:#ffa0a0; text-decoration: line-through\">She " +
                            "</font>", diffList.First().text);

            _helper.ReplaceStyledTags(diffList.ElementAt(1));
            Assert.AreEqual("<font style=\"background:#069edb\">She </font>", diffList.ElementAt(1).text);

            _helper.ReplaceStyledTags(diffList.Last());
            Assert.AreEqual("went to the store.</p>", diffList.Last().text);
        }
Exemplo n.º 5
0
        public void ReplaceStyledTags()
        {
            string s1 = "<p>Pepper piper <i>picked a peck of <strong>pickled peppers and</strong></i> went home.</p>";
            string s2 = "<p>Peter parker <i>picked a peck of <strong>pickled</strong> peppers and came</i> home.</p>";

            _helper = new DMPCWMTHelper();
            _helper.TagParser(ref s1, ref s2);
            List <Diff> diffList = _dmp.diff_wordMode(s1, s2);

            _helper.DefineStyleDupDict("background:#069edb", "background:#ffa0a0; text-decoration: line-through");
            _finished = diffList.First().text;
            System.Diagnostics.Debug.WriteLine(_finished);

            _helper.ReplaceStyledTags(diffList.First());
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\"><p><font style=\"" +
                            "background:#ffa0a0; text-decoration: line-through\">Pepper piper </font>", diffList.First().text);

            _helper.ReplaceStyledTags(diffList.ElementAt(1));
            Assert.AreEqual("<font style=\"background:#069edb\">Peter parker </font>", diffList.ElementAt(1).text);

            _helper.ReplaceStyledTags(diffList.ElementAt(2));

            _helper.ReplaceStyledTags(diffList.ElementAt(3));
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\"><strong>pickled " +
                            "</strong></font>", diffList.ElementAt(3).text);

            _helper.ReplaceStyledTags(diffList.ElementAt(4));
            Assert.AreEqual("<font style=\"background:#069edb\"><strong>pickled</strong> " +
                            "</font>", diffList.ElementAt(4).text);

            Diff newDiff = _helper.ReplaceStyledTags(diffList.ElementAt(5));

            Assert.AreEqual(newDiff.operation, Operation.DELETE);

            _helper.ReplaceStyledTags(newDiff);
            Assert.AreEqual("<font style=\"background:#ffa0a0; text-decoration: line-through\">" +
                            "<strong>peppers </strong></font>", newDiff.text);

            _helper.ReplaceStyledTags(diffList.ElementAt(5));
            Assert.AreEqual("<font style=\"background:#069edb\">peppers </font>", diffList.ElementAt(5).text);

            _helper.ReplaceStyledTags(diffList.ElementAt(6));
            _helper.ReplaceStyledTags(diffList.ElementAt(7));
            Assert.AreEqual("<font style=\"background:#069edb\"><i>and came</i> </font>", diffList.ElementAt(7).text);

            _helper.ReplaceStyledTags(diffList.Last());
            Assert.AreEqual("home.</p>", diffList.Last().text);
        }