Exemple #1
0
        public void TestSubscriberandListener()
        {
            _epService.EPAdministrator.Configuration.AddEventType(
                "SupportBean", typeof(SupportBean));
            _epService.EPAdministrator.CreateEPL(
                "insert into A1 select s.*, 1 as a from SupportBean as s");
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select a1.* from A1 as a1");

            var listener   = new SupportUpdateListener();
            var subscriber = new MySubscriberRowByRowObjectArr();

            stmt.Events    += listener.Update;
            stmt.Subscriber = subscriber;
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreEqual("E1", theEvent.Get("TheString"));
            Assert.AreEqual(1, theEvent.Get("IntPrimitive"));
            Assert.IsTrue(theEvent.Underlying is Pair <object, IDictionary <string, object> >);

            foreach (String property in stmt.EventType.PropertyNames)
            {
                EventPropertyGetter getter = stmt.EventType.GetGetter(property);

                getter.Get(theEvent);
            }
        }
Exemple #2
0
        private void RunAssertionObjectArrayDelivery(EventRepresentationEnum eventRepresentationEnum)
        {
            var         subscriber = new MySubscriberRowByRowObjectArr();
            EPStatement stmt       = _epService.EPAdministrator.CreateEPL(
                eventRepresentationEnum.GetAnnotationText()
                + " select TheString, IntPrimitive from SupportBean.std:unique(TheString)");

            stmt.Subscriber = subscriber;
            Assert.AreEqual(eventRepresentationEnum.GetOutputClass(),
                            stmt.EventType.UnderlyingType);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertEqualsAnyOrder(
                subscriber.GetAndResetIndicate()[0], new Object[]
            {
                "E1", 1
            }
                );

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 10));
            EPAssertionUtil.AssertEqualsAnyOrder(
                subscriber.GetAndResetIndicate()[0], new Object[]
            {
                "E2", 10
            }
                );

            _epService.EPAdministrator.DestroyAllStatements();
        }