public void TestFlush() { var countdownEvent = new CountdownEvent(2); var eventDispatcher = new TestEventDispatcher(countdownEvent); SetEventProcessor(eventDispatcher); UserEvent userEvent = BuildConversionEvent(EventName); EventProcessor.Process(userEvent); EventProcessor.Flush(); eventDispatcher.ExpectConversion(EventName, TestUserId); EventProcessor.Process(userEvent); EventProcessor.Flush(); eventDispatcher.ExpectConversion(EventName, TestUserId); Thread.Sleep(1500); Assert.True(eventDispatcher.CompareEvents()); Assert.True(countdownEvent.Wait(TimeSpan.FromMilliseconds(MAX_DURATION_MS / 2)), "Exceeded timeout waiting for notification."); Assert.AreEqual(0, EventProcessor.EventQueue.Count); }