Ejemplo n.º 1
0
        public void test_low_rate_in_range()
        {
            var  seconds           = 2;
            var  eventsPerInterval = 1;
            var  g     = new PrimitiveEventGenerator(eventsPerInterval, TimeUnit.Second, new EventType("T"));
            var  sw    = new Stopwatch();
            long count = 0;

            sw.Start();
            while (sw.ElapsedMilliseconds < seconds * 1000)
            {
                count += g.generate().Length;
            }

            Assert.InRange(count / (float)(seconds * eventsPerInterval), 0.999, 1.001);
        }
Ejemplo n.º 2
0
        public void test_shorter_duration_fewer_events()
        {
            var  seconds           = 2;
            var  eventsPerInterval = 100000;
            var  g     = new PrimitiveEventGenerator(eventsPerInterval, TimeUnit.Second, new EventType("T"));
            var  sw    = new Stopwatch();
            long count = 0;

            sw.Start();
            while (sw.ElapsedMilliseconds < (seconds - 1) * 1000)
            {
                count += g.generate().Length;
            }

            var actualratio = count / (float)(seconds * eventsPerInterval);

            Assert.NotInRange(actualratio, 0.999, 1.001);
            Assert.True(actualratio < 1.0);
        }