public void Test_WriteEvent_ZeroKwds() { TestUtilities.CheckNoEventSourcesRunning("Start"); using (var log = new EventSourceTest()) { using (var el = new LoudListener()) { // match any kwds == 0 el.EnableEvents(log, 0, 0); // Fire an event without a kwd: EventWithEscapingMessage // 1. Validate that the event fires when ETW event method called unconditionally log.EventWithEscapingMessage("Hello world!", 10); Assert.NotNull(LoudListener.LastEvent); Assert.Equal(2, LoudListener.LastEvent.Payload.Count); Assert.Equal("Hello world!", (string)LoudListener.LastEvent.Payload[0]); Assert.Equal(10, (int)LoudListener.LastEvent.Payload[1]); // reset LastEvent LoudListener.LastEvent = null; // 2. Validate that the event fires when ETW event method call is guarded by IsEnabled if (log.IsEnabled(EventLevel.Informational, 0)) log.EventWithEscapingMessage("Goodbye skies!", 100); Assert.NotNull(LoudListener.LastEvent); Assert.Equal(2, LoudListener.LastEvent.Payload.Count); Assert.Equal("Goodbye skies!", (string)LoudListener.LastEvent.Payload[0]); Assert.Equal(100, (int)LoudListener.LastEvent.Payload[1]); } } TestUtilities.CheckNoEventSourcesRunning("Stop"); }