public void ProcessRemovesCorrectLength() { HTMLDualTagFormatting uTag = GetUTag(); string valid = "HelloWorld"; string input = String.Format("<u>{0}</u>", valid); string processed = uTag.Process(input, uTag.GetAllPositons(input).First()); Assert.AreEqual(input.Length, processed.Length + uTag.TotalLength); }
public void Bug_1_br_failure() { //Throws: ArgumnetException //This is the original code that caused the bug to be produced. //redux will reduce the code to the minimum value needed to reproduce. HTMLDualTagFormatting u = new HTMLDualTagFormatting("u"); HTMLDualTagFormatting b = new HTMLDualTagFormatting("b"); HTMLDualTagFormatting i = new HTMLDualTagFormatting("i"); SingleHTMLTag br = new SingleHTMLTag("br"); //Note that the >> was there unintentionally. string bug_1 = "Hi There, this is an initial Test.<br/><br/><u>Hello World</u>><br/><b>Hello World</b>><br/><i>Hello World</i>"; var res = StringProcessor.ProcessString(bug_1, new List <TextFormattingRule> { u, b, i, br }); }
public void TestNormalWrap() { HTMLDualTagFormatting u = new HTMLDualTagFormatting("uu"); HTMLDualTagFormatting b = new HTMLDualTagFormatting("b"); string toTest = "<uu><b>aa</b></uu>"; WrappedFormat r = new WrappedFormat(u, new Position(4, 13)); r.AddRule(b, Position.OverlapType.Total); Position mod = r.ModifiedPosition; Assert.AreEqual(0, mod.Start); Assert.AreEqual(2, mod.End); }
public void Bug_1_br_redux() { HTMLDualTagFormatting u = new HTMLDualTagFormatting("u"); HTMLDualTagFormatting b = new HTMLDualTagFormatting("b"); HTMLDualTagFormatting i = new HTMLDualTagFormatting("i"); SingleHTMLTag br = new SingleHTMLTag("br"); //Explanation of cause: //Initially: Problem was due to an instance of WrappedFormat being created over a single HTML tag with a wrapped rule inserted. //This should never have happened in the first place, code was modified to throw an error earlier on. //Once found, the Position was from 34:39 and 39:44, this was deemed by the code to be an overlap of type: OverlapType.Right //Unit tests were added to fix this (TestPosition_bug_1), now returns OverlapType.None string bug_1 = "Hi There, this is an initial Test.<br/><br/><u>Hello World</u>><br/><b>Hello World</b>><br/><i>Hello World</i>"; var res = StringProcessor.ProcessString(bug_1, new List <TextFormattingRule> { u, b, i, br }); //only need to assert that no error was created. }
public void Bug_2_br_redux() { //Same code as Bug_1, the displayed text was shown incorrectly. HTMLDualTagFormatting u = new HTMLDualTagFormatting("u"); HTMLDualTagFormatting b = new HTMLDualTagFormatting("b"); HTMLDualTagFormatting i = new HTMLDualTagFormatting("i"); SingleHTMLTag br = new SingleHTMLTag("br"); //Looking a the output text, it was as expected. //Looking at the positioning of the breaks, it was as expected. //Output seemed perfect, there was a Bug using System.Windows.Forms.RichTextBox, assumed: start,end, was actually start, length //TODO: Before this is marked as done, add an adapter to the presentation layer. string bug_1 = "<br/><br/><u>Hello World</u>><br/><b>Hello World</b>><br/><i>Hello World</i>"; var res = StringProcessor.ProcessString(bug_1, new List <TextFormattingRule> { u, b, i, br }); string result = res.Value; Assert.AreEqual("Hello World>Hello World>Hello World", result); Assert.Inconclusive(); }