ExtractTextUnitTests.cs 969 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Xunit;
  2. using analyzeJSON;
  3. using System;
  4. using System.Collections.Generic;
  5. using Newtonsoft.Json.Linq;
  6. namespace analyzeJSONTests
  7. {
  8. public class ExtractTextUnitTests
  9. {
  10. [Fact]
  11. public void ExtractText_NullKeys()
  12. {
  13. Assert.Throws<ArgumentNullException>(() => new ExtractText(null));
  14. }
  15. [Fact]
  16. public void ExtractText_AllGood()
  17. {
  18. dynamic token = new JObject();
  19. token.one = "Lorem ipsum dolor";
  20. token.two = "Lorem ipsum dolor";
  21. token.three = "Lorem\nipsum dolor";
  22. var keys = new Dictionary<string, bool>
  23. {
  24. ["one"] = true,
  25. ["two"] = false
  26. };
  27. var test = new ExtractText(keys);
  28. test.Extract(token.one);
  29. test.Extract(token.two);
  30. test.Extract(token.three);
  31. Assert.Equal(2, test.Result.Count);
  32. }
  33. }
  34. }