Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix lab failure
  • Loading branch information
agocke authored and github-actions committed Aug 20, 2021
commit d305926f99a2f75eb62e6b58ead73f2187e6d730
24 changes: 13 additions & 11 deletions src/tests/tracing/runtimeeventsource/RuntimeEventSourceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@

public class RuntimeEventListener : EventListener
{
private readonly Dictionary<string, bool> observedEvents = new Dictionary<string, bool>() {
{ "appContextSwitch", false },
{ "appContextBoolAsStringData", false },
private readonly Dictionary<string, bool> _observedEvents = new Dictionary<string, bool>();

private static readonly string[] s_expectedEvents = new[] {
"appContextSwitch",
"appContextBoolAsStringData",
};

private static readonly string[] s_unexpectedEvents = new[] {
Expand All @@ -58,32 +60,32 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
// Check AppContext switches
if (eventData is { EventName: "LogAppContextSwitch",
Payload: { Count: 2 } } &&
eventData.Payload[0] is string switchName)
Payload: { Count: 2 } })
{
observedEvents[switchName] = ((int)eventData.Payload[1]) == 1;
var switchName = (string)eventData.Payload[0];
_observedEvents[switchName] = ((int)eventData.Payload[1]) == 1;
return;
}
}

public bool Verify()
{
foreach (var (k, v) in observedEvents)
foreach (var key in s_expectedEvents)
{
if (!v)
if (!_observedEvents[key])
{
Console.WriteLine($"Could not find key {k}");
Console.WriteLine($"Could not find key {key}");
return false;
}
else
{
Console.WriteLine($"Saw {k}");
Console.WriteLine($"Saw {key}");
}
}

foreach (var key in s_unexpectedEvents)
{
if (observedEvents.ContainsKey(key))
if (_observedEvents.ContainsKey(key))
{
Console.WriteLine($"Should not have seen {key}");
return false;
Expand Down