public async Task Can_subscribe_to_diagnostic_source() { using var instrumentation = new DiagnosticSourceInstrumentation(_ => _observer, l => l.Name == "TestSource", null); await instrumentation.StartAsync(CancellationToken.None); TestSource.Write("TestEvent", new TestEvent()); _events.Count.ShouldBe(1); _events.Find(kvp => kvp.Key == "TestEvent").Value.ShouldNotBeNull(); }
public async Task Can_subscribe_with_filter() { using var instrumentation = new DiagnosticSourceInstrumentation( _ => _observer, l => l.Name == "TestSource", (eventType, _, _) => eventType == "SpecialEvent"); await instrumentation.StartAsync(CancellationToken.None); if (TestSource.IsEnabled("TestEvent")) { TestSource.Write("TestEvent", new TestEvent()); } if (TestSource.IsEnabled("SpecialEvent")) { TestSource.Write("SpecialEvent", new TestEvent()); } _events.Count.ShouldBe(1); }