Browse Source

Added AnalysisResult

Piotr Czajkowski 2 years ago
parent
commit
23df13073c
2 changed files with 8 additions and 0 deletions
  1. 4 0
      AnalyzeStructure.cs
  2. 4 0
      analyzeJSONTests/AnalyzeStructureIntegrationTests.cs

+ 4 - 0
AnalyzeStructure.cs

@@ -3,6 +3,8 @@ using Newtonsoft.Json.Linq;
 
 namespace analyzeJSON
 {
+    public record AnalysisResult(Dictionary<string, int> Nodes, Dictionary<string, int> Leafs);
+
     public class AnalyzeStructure
     {
         private Dictionary<string, int> nodes = new Dictionary<string, int>();
@@ -40,5 +42,7 @@ namespace analyzeJSON
                     leafs.Add(tokenName, 1);
             }
         }
+
+        public AnalysisResult Result => new AnalysisResult(nodes, leafs);
     }
 }

+ 4 - 0
analyzeJSONTests/AnalyzeStructureIntegrationTests.cs

@@ -13,6 +13,10 @@ namespace analyzeJSONTests
             var test = new AnalyzeJSON(testFile);
             var analyze = new AnalyzeStructure();
             test.Traverse((token) => analyze.AnalyzeToken(token));
+
+            var result = analyze.Result;
+            Assert.Equal(9, result.Nodes.Count);
+            Assert.Equal(9, result.Leafs.Count);
         }
     }
 }