public void MockETWProcessWaitsForTaskToEnd() { const string anySessionName = "session"; bool eventTriggered = false; using (var processor = new MockETWProcessor(anySessionName)) { processor.EventProcessed += ev => eventTriggered = true; processor.SubscribeToEvents(TestLogger.Write, EventLevel.Verbose); var t = new Task(processor.Process); t.Start(); while (t.Status != TaskStatus.Running) // we must wait for the task to actually start { Thread.Sleep(10); } TestLogger.Write.String("Hi"); processor.StopProcessing(); t.Wait(); Assert.IsTrue(eventTriggered); } }
public void MockETWProcessorTriggersForSubscribedEventSources() { const string anySessionName = "session"; bool eventTriggered = false; using (var processor = new MockETWProcessor(anySessionName)) { processor.EventProcessed += ev => eventTriggered = true; processor.SubscribeToEvents(TestLogger.Write, EventLevel.Verbose); processor.ProcessAsync(); TestLogger.Write.String("Hi"); processor.StopProcessing(); Assert.IsTrue(eventTriggered); } }