AnalyzeJSONIntegrationTests.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using analyzeJSON;
  2. using Xunit;
  3. using System;
  4. using System.Collections.Generic;
  5. using Newtonsoft.Json.Linq;
  6. namespace analyzeJSONTests
  7. {
  8. public class AnalyzeJSONIntegrationTests
  9. {
  10. private static readonly string testFile = @"testFiles/complex.json";
  11. [Fact]
  12. public void AnalyzeJSON_AllGood()
  13. {
  14. _ = new AnalyzeJSON(testFile);
  15. }
  16. [Fact]
  17. public void TwoActionsAtOnce()
  18. {
  19. var test = new AnalyzeJSON(testFile);
  20. var analyze = new AnalyzeStructure();
  21. var stats = new Statistics();
  22. var actions = new List<Action<JToken>> {
  23. analyze.AnalyzeToken,
  24. stats.RunStatistics
  25. };
  26. var status = test.Traverse(actions);
  27. Assert.True(status.Success);
  28. Assert.Empty(status.Message);
  29. var result = analyze.Result;
  30. Assert.Equal(10, result.Nodes.Count);
  31. Assert.Equal(11, result.Leafs.Count);
  32. Assert.Equal(11, stats.Result.NodeCounts.Count);
  33. Assert.Equal(168, stats.Result.TotalWordCount);
  34. }
  35. }
  36. }