private static void PrintDiff(string expectedLine, string gotLine, string testName) { var diffBuilder = new InlineDiffBuilder(new Differ()); var diff = diffBuilder.BuildDiffModel(expectedLine, gotLine); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"[!] Error in {testName}"); foreach (var line in diff.Lines) { switch (line.Type) { case ChangeType.Inserted: Console.ForegroundColor = ConsoleColor.Red; Console.Write("+ "); break; case ChangeType.Deleted: Console.ForegroundColor = ConsoleColor.Green; Console.Write("- "); break; default: Console.ForegroundColor = ConsoleColor.White; Console.Write(" "); break; } Console.WriteLine(line.Text); } }
public DiffPaneModel BuildDiffModel(string oldText, string newText) { if (oldText == null) { throw new ArgumentNullException(nameof(oldText)); } if (newText == null) { throw new ArgumentNullException(nameof(newText)); } DiffPaneModel diffPaneModel = new DiffPaneModel(); InlineDiffBuilder.BuildDiffPieces(this.differ.CreateLineDiffs(oldText, newText, false), diffPaneModel.Lines); return(diffPaneModel); }