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])); }
public void TagParser() { string s1 = "<p>Peter piper picked a peck of pickled pepper & went home.</p>"; string s2 = "<h1>Peter parker penned a <p>peck</p> of pickled peppers & came home.</h1>"; _helper = new DMPCWMTHelper(); _helper.TagParser(ref s1, ref s2); Assert.AreEqual(_helper.HtmlTags.Count, 4); Assert.AreEqual(_helper.HtmlTags["<p>"], (char)0xE000); Assert.AreEqual(_helper.HtmlTags["</p>"], (char)0xE001); Assert.AreEqual(_helper.HtmlTags["<h1>"], (char)0xE002); Assert.AreEqual(_helper.HtmlTags["</h1>"], (char)0xE003); Assert.IsTrue(!s2.Contains("<")); //The test below is to demonstrate that the unicode characters are not affected by html encoding s1 = HttpUtility.HtmlEncode(s1); _finished = (char)0xE000 + "Peter piper picked a peck of pickled pepper &amp; " + "went home." + (char)0xE001; Assert.IsTrue(_sc.Equals(s1, _finished)); }
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()); }
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); }