public void DoesNotReportEventsBeforeActivation() { var healthReporterMock = new Mock <IHealthReporter>(); var observer = new Mock <IObserver <EventData> >(); var inputConfiguration = new List <EtwProviderConfiguration>(); inputConfiguration.Add(new EtwProviderConfiguration { ProviderName = TestTraceEventSession.TestEtwProviderName }); using (var input = new EtwInput(inputConfiguration, healthReporterMock.Object)) using (input.Subscribe(observer.Object)) { var traceSession = new TestTraceEventSession(); input.SessionFactory = () => traceSession; traceSession.ReportEvent(LogLevel.Informational, 0, "First"); input.Activate(); traceSession.ProcessingStarted.WaitOne(TraceSessionActivationTimeout); traceSession.ReportEvent(LogLevel.Informational, 0, "Second"); observer.Verify(o => o.OnNext(It.IsAny <EventData>()), Times.Exactly(1)); observer.Verify(o => o.OnNext(It.Is <EventData>(data => data.Payload["Message"].Equals("Second") && data.Level == LogLevel.Informational ))); VerifyNoErrorsOrWarnings(healthReporterMock); } }
public void ReportsProblemsWhenConfigurationIsInvalid() { var healthReporterMock = new Mock <IHealthReporter>(); var observer = new Mock <IObserver <EventData> >(); var inputConfiguration = new List <EtwProviderConfiguration>(); using (var input = new EtwInput(inputConfiguration, healthReporterMock.Object)) { var traceSession = new TestTraceEventSession(); input.SessionFactory = () => traceSession; input.Activate(); traceSession.ProcessingStarted.WaitOne(TraceSessionActivationTimeout); healthReporterMock.Verify(o => o.ReportWarning(It.Is <string>(s => s.Contains("no providers configured")), It.IsAny <string>()), Times.Exactly(1)); } healthReporterMock.ResetCalls(); var providerConfiguration = new EtwProviderConfiguration(); string validationError; Assert.False(providerConfiguration.Validate(out validationError)); inputConfiguration.Add(providerConfiguration); using (var input = new EtwInput(inputConfiguration, healthReporterMock.Object)) { var traceSession = new TestTraceEventSession(); input.SessionFactory = () => traceSession; input.Activate(); healthReporterMock.Verify(o => o.ReportWarning(It.Is <string>(s => s.Contains(validationError)), It.IsAny <string>()), Times.Exactly(1)); } }