예제 #1
0
        public void TestNotUsingEngineThread()
        {
            _coordinator = new AdapterCoordinatorImpl(_epService, false);
            _coordinator.Coordinate(new CSVInputAdapter(_container, _epService, _noTimestampsNotLooping));
            _coordinator.Coordinate(new CSVInputAdapter(_container, _epService, _timestampsNotLooping));

            long startTime = Environment.TickCount;

            _coordinator.Start();
            long endTime = Environment.TickCount;

            // The last event should be sent after 500 ms
            Assert.IsTrue(endTime - startTime > 500);

            Assert.AreEqual(6, _listener.GetNewDataList().Count);
            AssertEvent(0, 1, 1.1, "noTimestampOne.one");
            AssertEvent(1, 1, 1.1, "timestampOne.one");
            AssertEvent(2, 2, 2.2, "noTimestampOne.two");
            AssertEvent(3, 3, 3.3, "noTimestampOne.three");
            AssertEvent(4, 3, 3.3, "timestampOne.three");
            AssertEvent(5, 5, 5.5, "timestampOne.five");
        }
예제 #2
0
        public void TestExternalTimer()
        {
            _coordinator = new AdapterCoordinatorImpl(_epService, false, true, false);
            _coordinator.Coordinate(new CSVInputAdapter(_container, _epService, _noTimestampsNotLooping));
            _coordinator.Coordinate(new CSVInputAdapter(_container, _epService, _timestampsNotLooping));

            long startTime = Environment.TickCount;

            _coordinator.Start();
            long endTime = Environment.TickCount;

            // Check that we haven't been kept waiting
            Assert.That(endTime - startTime, Is.LessThan(100));

            Assert.AreEqual(6, _listener.GetNewDataList().Count);
            AssertEvent(0, 1, 1.1, "noTimestampOne.one");
            AssertEvent(1, 1, 1.1, "timestampOne.one");
            AssertEvent(2, 2, 2.2, "noTimestampOne.two");
            AssertEvent(3, 3, 3.3, "noTimestampOne.three");
            AssertEvent(4, 3, 3.3, "timestampOne.three");
            AssertEvent(5, 5, 5.5, "timestampOne.five");
        }
예제 #3
0
        public void TestRun()
        {
            _coordinator.Coordinate(new CSVInputAdapter(_container, _timestampsNotLooping));
            _coordinator.Coordinate(new CSVInputAdapter(_container, _timestampsLooping));
            _coordinator.Coordinate(new CSVInputAdapter(_container, _noTimestampsNotLooping));
            _coordinator.Coordinate(new CSVInputAdapter(_container, _noTimestampsLooping));

            // TimeInMillis is 0
            Assert.IsFalse(_listener.GetAndClearIsInvoked());
            _coordinator.Start();

            // TimeInMillis is 50
            SendTimeEvent(50);

            // TimeInMillis is 100
            SendTimeEvent(50);
            AssertEvent(0, 1, 1.1, "timestampOne.one");
            AssertEvent(1, 1, 1.1, "noTimestampOne.one");
            AssertSizeAndReset(2);

            // TimeInMillis is 150
            SendTimeEvent(50);
            Assert.IsFalse(_listener.GetAndClearIsInvoked());

            // TimeInMillis is 200
            SendTimeEvent(50);
            AssertEvent(0, 2, 2.2, "timestampTwo.two");
            AssertEvent(1, 2, 2.2, "noTimestampOne.two");
            AssertEvent(2, 2, 2.2, "noTimestampTwo.two");
            AssertSizeAndReset(3);

            // TimeInMillis is 250
            SendTimeEvent(50);

            // TimeInMillis is 300
            SendTimeEvent(50);
            AssertEvent(0, 3, 3.3, "timestampOne.three");
            AssertEvent(1, 3, 3.3, "noTimestampOne.three");
            AssertSizeAndReset(2);

            // TimeInMillis is 350
            SendTimeEvent(50);
            Assert.IsFalse(_listener.GetAndClearIsInvoked());

            _coordinator.Pause();

            // TimeInMillis is 400
            SendTimeEvent(50);
            Assert.IsFalse(_listener.GetAndClearIsInvoked());

            // TimeInMillis is 450
            SendTimeEvent(50);
            Assert.IsFalse(_listener.GetAndClearIsInvoked());

            _coordinator.Resume();

            AssertEvent(0, 4, 4.4, "timestampTwo.four");
            AssertEvent(1, 4, 4.4, "noTimestampTwo.four");
            AssertSizeAndReset(2);

            // TimeInMillis is 500
            SendTimeEvent(50);
            AssertEvent(0, 5, 5.5, "timestampOne.five");
            AssertSizeAndReset(1);

            // TimeInMillis is 600
            SendTimeEvent(100);
            AssertEvent(0, 6, 6.6, "timestampTwo.six");
            AssertEvent(1, 2, 2.2, "noTimestampTwo.two");
            AssertSizeAndReset(2);

            // TimeInMillis is 800
            SendTimeEvent(200);
            AssertEvent(0, 2, 2.2, "timestampTwo.two");
            AssertEvent(1, 4, 4.4, "noTimestampTwo.four");
            AssertSizeAndReset(2);

            _coordinator.Stop();
            SendTimeEvent(1000);
            Assert.IsFalse(_listener.GetAndClearIsInvoked());
        }