public static void TestRemoveDoubleSpace(string original, string expected) { var actual = DrCmdTextBuilder.RemoveDoubleSpace(original); Assert.AreEqual(expected, actual, string.Format("Actual text '{0}' not equals expected '{1}'.", actual, expected)); }
public static void TestGetElementCountForNewLine(string[] words, DrCmdTextBuilderFormat format, int startIndex) { var actual = DrCmdTextBuilder.GetElementCountForNewLine(startIndex, format, words); var length = 0; int expected = startIndex; while (expected < words.Length) { length += words[expected].Length + 1; expected++; if ((expected < words.Length) && (length + words[expected].Length > format.Length)) { break; } } expected = expected - startIndex; Assert.AreEqual(expected, actual, string.Format("Actual element count'{0}' not equals expected '{1}'.", actual, expected)); var lineLenght = String.Join(" ", words, startIndex, actual); Assert.IsTrue(lineLenght.Length <= format.Length, string.Format("Actual text '{0}' not equals format.lenght '{1}'.", lineLenght, format.Length)); // The next element can be joined to line. if (expected + startIndex + 1 < words.Length) { Assert.IsFalse( ((lineLenght.Length + 1 + words[startIndex + expected + 1].Length) <= format.Length), "The next element can be joined to line."); } }
public static void TestNormalyzeTextArray(string[] original, string[] expected) { var actual = DrCmdTextBuilder.NormalyzeTextArray(original); Assert.IsTrue(CompareStringArray(expected, actual), string.Format("Actual text '{0}' not equals expected '{1}'.", actual, expected)); }
public static void TestNormalyzeText(string original, string expected) { var actual = DrCmdTextBuilder.NormalyzeText(original); Assert.AreEqual(expected, actual, string.Format("Actual text '{0}' not equals expected '{1}'.", actual, expected)); }
/// <summary> /// Integrity check the of words and all text. /// </summary> /// <param name="original"></param> /// <param name="formated"></param> public void IntegrityTextCheck(string original, string formated) { var originalWords = DrCmdTextBuilder.SplitAndNormalyzeText(original); var formatedWords = DrCmdTextBuilder.SplitAndNormalyzeText(formated); Assert.IsTrue(CompareStringArray(originalWords, formatedWords), "There was a loss of data when formatting."); }
public void TestBuildTextJustifyTrue() { var marginLeft = 10; var textWidth = 80; var justify = true; var drTextFormat = new DrCmdTextBuilderFormat(marginLeft, textWidth, justify, false); var drCmdTextBuilder = new DrCmdTextBuilder(drTextFormat); var result = drCmdTextBuilder.BuildText(textSample1); ValidateFormatedText(drTextFormat, textSample1, result); }