tracks/csharp/generators/Exercises/WordCount.cs in trackler-2.2.1.27 vs tracks/csharp/generators/Exercises/WordCount.cs in trackler-2.2.1.28

- old
+ new

@@ -1,8 +1,8 @@ using Generators.Input; -using Newtonsoft.Json.Linq; using System.Collections.Generic; +using System.Linq; namespace Generators.Exercises { public class WordCount : Exercise { @@ -10,18 +10,15 @@ { foreach (var canonicalDataCase in canonicalData.Cases) { canonicalDataCase.UseVariableForExpected = true; canonicalDataCase.UseVariableForTested = true; - canonicalDataCase.Expected = ((JObject)canonicalDataCase.Expected).ToObject<Dictionary<string, int>>(); + canonicalDataCase.Expected = ConvertExpected(canonicalDataCase.Expected); } } - protected override HashSet<string> AddAdditionalNamespaces() - { - return new HashSet<string>() - { - typeof(Dictionary<string, int>).Namespace - }; - } + private static dynamic ConvertExpected(dynamic expected) + => ((Dictionary<string, object>)expected).ToDictionary(kv => kv.Key, kv => int.Parse(kv.Value.ToString())); + + protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string> { typeof(Dictionary<string, int>).Namespace }; } }