コード例 #1
0
        public void TestSensorPerEvent()
        {
            String stmtString =
                "SELECT irstream * " +
                "FROM\n " +
                typeof(SupportSensorEvent).FullName + "#groupwin(type)#time(1 hour)#unique(device)#sort(1, measurement desc) as high ";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtString);

            stmt.Events += _testListener.Update;

            EPRuntime runtime = _epService.EPRuntime;

            SupportSensorEvent eventOne = new SupportSensorEvent(1, "Temperature", "Device1", 5.0, 96.5);

            runtime.SendEvent(eventOne);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventOne }, null);

            SupportSensorEvent eventTwo = new SupportSensorEvent(2, "Temperature", "Device2", 7.0, 98.5);

            runtime.SendEvent(eventTwo);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventTwo }, new Object[] { eventOne });

            SupportSensorEvent eventThree = new SupportSensorEvent(3, "Temperature", "Device2", 4.0, 99.5);

            runtime.SendEvent(eventThree);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventThree }, new Object[] { eventTwo });

            IEnumerator <EventBean> it       = stmt.GetEnumerator();
            SupportSensorEvent      theEvent = (SupportSensorEvent)it.Advance().Underlying;

            Assert.AreEqual(3, theEvent.Id);
        }
コード例 #2
0
ファイル: ViewLengthBatch.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select irstream * from SupportBean#length_batch(1)";
                env.CompileDeployAddListenerMileZero(epl, "s0");
                var events = Get10Events();

                SendEvent(events[0], env);
                EPAssertionUtil.AssertUnderlyingPerRow(
                    env.Listener("s0").AssertInvokedAndReset(),
                    new[] {events[0]},
                    null);
                EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, env.Statement("s0").GetEnumerator());

                SendEvent(events[1], env);
                EPAssertionUtil.AssertUnderlyingPerRow(
                    env.Listener("s0").AssertInvokedAndReset(),
                    new[] {events[1]},
                    new[] {events[0]});
                EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, env.Statement("s0").GetEnumerator());

                SendEvent(events[2], env);
                EPAssertionUtil.AssertUnderlyingPerRow(
                    env.Listener("s0").AssertInvokedAndReset(),
                    new[] {events[2]},
                    new[] {events[1]});
                EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, env.Statement("s0").GetEnumerator());

                env.UndeployAll();
            }
コード例 #3
0
ファイル: TestViewLengthBatch.cs プロジェクト: valmac/nesper
        public void TestLengthBatchSize2()
        {
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select irstream * from " + typeof(SupportBean).FullName + "#length_batch(2)");

            stmt.Events += _listener.Update;

            SendEvent(_events[0]);
            Assert.IsFalse(_listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { _events[0] }, stmt.GetEnumerator());

            SendEvent(_events[1]);
            EPAssertionUtil.AssertUnderlyingPerRow(_listener.AssertInvokedAndReset(), new SupportBean[] { _events[0], _events[1] }, null);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(_events[2]);
            Assert.IsFalse(_listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { _events[2] }, stmt.GetEnumerator());

            SendEvent(_events[3]);
            EPAssertionUtil.AssertUnderlyingPerRow(_listener.AssertInvokedAndReset(), new SupportBean[] { _events[2], _events[3] }, new SupportBean[] { _events[0], _events[1] });
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(_events[4]);
            Assert.IsFalse(_listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { _events[4] }, stmt.GetEnumerator());

            SendEvent(_events[5]);
            EPAssertionUtil.AssertUnderlyingPerRow(_listener.AssertInvokedAndReset(), new SupportBean[] { _events[4], _events[5] }, new SupportBean[] { _events[2], _events[3] });
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());
        }
コード例 #4
0
        private void RunAssertionSensorPerEvent(EPServiceProvider epService)
        {
            string stmtString =
                "SELECT irstream * " +
                "FROM\n " +
                typeof(SupportSensorEvent).FullName + "#groupwin(type)#time(1 hour)#unique(device)#sort(1, measurement desc) as high ";

            EPStatement stmt         = epService.EPAdministrator.CreateEPL(stmtString);
            var         testListener = new SupportUpdateListener();

            stmt.Events += testListener.Update;

            EPRuntime runtime = epService.EPRuntime;

            var eventOne = new SupportSensorEvent(1, "Temperature", "Device1", 5.0, 96.5);

            runtime.SendEvent(eventOne);
            EPAssertionUtil.AssertUnderlyingPerRow(testListener.AssertInvokedAndReset(), new object[] { eventOne }, null);

            var eventTwo = new SupportSensorEvent(2, "Temperature", "Device2", 7.0, 98.5);

            runtime.SendEvent(eventTwo);
            EPAssertionUtil.AssertUnderlyingPerRow(testListener.AssertInvokedAndReset(), new object[] { eventTwo }, new object[] { eventOne });

            var eventThree = new SupportSensorEvent(3, "Temperature", "Device2", 4.0, 99.5);

            runtime.SendEvent(eventThree);
            EPAssertionUtil.AssertUnderlyingPerRow(testListener.AssertInvokedAndReset(), new object[] { eventThree }, new object[] { eventTwo });

            SupportSensorEvent theEvent = (SupportSensorEvent)stmt.First().Underlying;

            Assert.AreEqual(3, theEvent.Id);

            stmt.Dispose();
        }
コード例 #5
0
        private void RunAssertionLengthBatchSize1(EPServiceProvider epService, SupportBean[] events)
        {
            EPStatement stmt = epService.EPAdministrator.CreateEPL(
                "select irstream * from " + typeof(SupportBean).FullName + "#length_batch(1)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(events[0], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(),
                                                   new SupportBean[] { events[0] }, null);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[1], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(),
                                                   new SupportBean[] { events[1] },
                                                   new SupportBean[] { events[0] });
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[2], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(),
                                                   new SupportBean[] { events[2] },
                                                   new SupportBean[] { events[1] });
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            stmt.Dispose();
        }
コード例 #6
0
        private void RunAssertionLengthBatchSize3And2Staggered(EPServiceProvider epService, SupportBean[] events)
        {
            if (SupportConfigFactory.SkipTest(typeof(ExecViewLengthBatch)))
            {
                return;
            }

            EPStatement stmt = epService.EPAdministrator.CreateEPL(
                "select irstream * from " + typeof(SupportBean).FullName + "#length_batch(3)#length_batch(2)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(events[0], epService);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[1], epService);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[2], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(), new SupportBean[] { events[0], events[1], events[2] }, null);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[3], epService);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[4], epService);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[5], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(),
                                                   new SupportBean[] { events[3], events[4], events[5] },
                                                   new SupportBean[] { events[0], events[1], events[2] });
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            stmt.Dispose();
        }