public void OCRHasOneCount(string k1, string k2, decimal pr) { WithObservableConcurrentDictionary withObservableConcurrentDictionary = new WithObservableConcurrentDictionary(); withObservableConcurrentDictionary.RecordCalculatedResults(k1, k2, pr); Assert.Equal(1, withObservableConcurrentDictionary.calculatedResults.Count()); }
public void OCRFlattened2And2(string str) { WithObservableConcurrentDictionary withObservableConcurrentDictionary = new WithObservableConcurrentDictionary(); var match = new Regex("(?<k1>.*?),(?<k2>.*?),(?<pr>.*?);").Match(str); while (match.Success) { withObservableConcurrentDictionary.RecordCalculatedResults(match.Groups["k1"].Value, match.Groups["k2"].Value, decimal.Parse(match.Groups["pr"].Value)); match = match.NextMatch(); } string fs = string.Empty; withObservableConcurrentDictionary.calculatedResults.OrderBy(kp => kp.Key) .SelectMany(pair => pair.Value.OrderBy(kp => kp.Key) .SelectMany(innerPair => $"{pair.Key},{innerPair.Key},{innerPair.Value};")) .ToList() .ForEach(x => fs += x.ToString()); Assert.Equal("k1=1,k2=1,1.1;k1=1,k2=2,1.2;k1=2,k2=1,2.1;k1=2,k2=2,2.2;", fs); }