DiffPlexReporter.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT License.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using DiffPlex;
  6. using DiffPlex.DiffBuilder;
  7. using DiffPlex.DiffBuilder.Model;
  8. namespace ReactiveTests.Tests
  9. {
  10. public class DiffPlexReporter
  11. {
  12. public void Report(string approvedText, string receivedText)
  13. {
  14. #if(!DEBUG)
  15. var diffBuilder = new InlineDiffBuilder(new Differ());
  16. var diff = diffBuilder.BuildDiffModel(approvedText, receivedText);
  17. foreach (var line in diff.Lines)
  18. {
  19. if (line.Type == ChangeType.Unchanged) continue;
  20. var prefix = " ";
  21. switch (line.Type)
  22. {
  23. case ChangeType.Inserted:
  24. prefix = "+ ";
  25. break;
  26. case ChangeType.Deleted:
  27. prefix = "- ";
  28. break;
  29. }
  30. Console.WriteLine("{0}{1}", prefix, line.Text);
  31. }
  32. #endif
  33. }
  34. }
  35. }