Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions test/Microsoft.ML.Functional.Tests/Debugging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, int>);
Assert.Equal(1, logWatcher.Lines[line]);
}
}

internal class LogWatcher {

public readonly IDictionary<string, int> Lines;
public readonly ConcurrentDictionary<string, int> Lines;

public LogWatcher()
{
Lines = new Dictionary<string, int>();
Lines = new ConcurrentDictionary<string, int>();
}

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);
}
}
}
Expand Down