public void TestPrevPriorAndAggregation()
        {
            SendTimeEvent("2002-05-1 8:00:00.000");
            _epService.EPAdministrator.CreateEPL("create context NineToFive as start (0, 9, *, *, *) end (0, 17, *, *, *)");

            String[] fields = "col1,col2,col3,col4,col5".Split(',');
            SupportUpdateListener listener  = new SupportUpdateListener();
            EPStatementSPI        statement = (EPStatementSPI)_epService.EPAdministrator.CreateEPL("context NineToFive " +
                                                                                                   "select prev(TheString) as col1, prevwindow(sb) as col2, prevtail(TheString) as col3, prior(1, TheString) as col4, sum(IntPrimitive) as col5 " +
                                                                                                   "from SupportBean.win:keepall() as sb");

            statement.Events += listener.Update;

            _epService.EPRuntime.SendEvent(new SupportBean());
            Assert.IsFalse(listener.IsInvoked);

            // now started
            SendTimeEvent("2002-05-1 9:00:00.000");
            SupportBean event1 = new SupportBean("E1", 1);

            _epService.EPRuntime.SendEvent(event1);
            Object[][] expected = new Object[][] { new Object[] { null, new SupportBean[] { event1 }, "E1", null, 1 } };
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, expected);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), statement.GetSafeEnumerator(), fields, expected);

            SupportBean event2 = new SupportBean("E2", 2);

            _epService.EPRuntime.SendEvent(event2);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1", new SupportBean[] { event2, event1 }, "E1", "E1", 3 });

            // now gone
            SendTimeEvent("2002-05-1 17:00:00.000");
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), statement.GetSafeEnumerator(), fields, null);

            _epService.EPRuntime.SendEvent(new SupportBean());
            Assert.IsFalse(listener.IsInvoked);
            AgentInstanceAssertionUtil.AssertInstanceCounts(statement.StatementContext, 0, 0, 0, 0);

            // now started
            SendTimeEvent("2002-05-2 9:00:00.000");

            SupportBean event3 = new SupportBean("E3", 9);

            _epService.EPRuntime.SendEvent(event3);
            expected = new Object[][] { new Object[] { null, new SupportBean[] { event3 }, "E3", null, 9 } };
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, expected);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), statement.GetSafeEnumerator(), fields, expected);
            AgentInstanceAssertionUtil.AssertInstanceCounts(statement.StatementContext, 1, 0, 3, 1);
        }
示例#2
0
        private void AssertIterator(EPStatementSPI statement, string[] fields, object[][] expected)
        {
            EventBean[] rows = EPAssertionUtil.EnumeratorToArray(statement.GetEnumerator());
            AssertIterator(rows, fields, expected);

            rows = EPAssertionUtil.EnumeratorToArray(statement.GetSafeEnumerator());
            AssertIterator(rows, fields, expected);
        }