Beispiel #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);
        }
        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();
        }