Example #1
0
        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);
        }
Example #2
0
        public void TestDrainOnClose()
        {
            var eventDispatcher = new TestEventDispatcher();

            SetEventProcessor(eventDispatcher);

            UserEvent userEvent = BuildConversionEvent(EventName);

            EventProcessor.Process(userEvent);
            eventDispatcher.ExpectConversion(EventName, TestUserId);

            Thread.Sleep(1500);

            Assert.True(eventDispatcher.CompareEvents());
            Assert.AreEqual(0, EventProcessor.EventQueue.Count);
        }
Example #3
0
        public void TestDispose()
        {
            var countdownEvent  = new CountdownEvent(2);
            var eventDispatcher = new TestEventDispatcher(countdownEvent);

            SetEventProcessor(eventDispatcher);

            Assert.IsTrue(EventProcessor.IsStarted);

            UserEvent userEvent = BuildConversionEvent(EventName);

            EventProcessor.Process(userEvent);
            eventDispatcher.ExpectConversion(EventName, TestUserId);

            EventProcessor.Dispose();

            Assert.True(eventDispatcher.CompareEvents());

            // make sure, isStarted is false while dispose.
            Assert.False(EventProcessor.IsStarted);
        }