diff --git a/test/Microsoft.ML.Functional.Tests/Debugging.cs b/test/Microsoft.ML.Functional.Tests/Debugging.cs index eaf0a0135c..b58433e157 100644 --- a/test/Microsoft.ML.Functional.Tests/Debugging.cs +++ b/test/Microsoft.ML.Functional.Tests/Debugging.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections.Concurrent; using System.Collections.Generic; using Microsoft.ML.Data; using Microsoft.ML.Functional.Tests.Datasets; @@ -185,26 +186,23 @@ public void ViewTrainingOutput() @"[Source=SdcaTrainerBase; Training, Kind=Info] Using best model from iteration 7."}; foreach (var line in expectedLines) { - Assert.Contains(line, logWatcher.Lines); + Assert.Contains(line, logWatcher.Lines as IReadOnlyDictionary); Assert.Equal(1, logWatcher.Lines[line]); } } internal class LogWatcher { - public readonly IDictionary Lines; + public readonly ConcurrentDictionary Lines; public LogWatcher() { - Lines = new Dictionary(); + Lines = new ConcurrentDictionary(); } public void ObserveEvent(object sender, LoggingEventArgs e) { - if (Lines.ContainsKey(e.Message)) - Lines[e.Message]++; - else - Lines[e.Message] = 1; + Lines.AddOrUpdate(e.Message, 1, (key, oldValue) => oldValue + 1); } } }