public static void RunAssertionCaseDynamic(EPServiceProvider epService) {
            // type resolved for each by the first event representation picking both up, i.e. the one with "r2" since that is the most specific URI
            var stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeOne");
            var listeners = SupportUpdateListener.MakeListeners(5);
            stmt.Events += listeners[0].Update;
            stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeTwo");
            stmt.Events += listeners[1].Update;

            // static senders
            var sender = epService.EPRuntime.GetEventSender("TestTypeOne");
            sender.SendEvent(
                MakePropertiesFromStrings(
                    new string[][] {
                        new string[] {
                            "r2",
                            "A"
                        }
                    }));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[0].AssertOneGetNewAndReset(), new object[] {"A"});
            Assert.IsFalse(listeners[0].IsInvoked);

            sender = epService.EPRuntime.GetEventSender("TestTypeTwo");
            sender.SendEvent(
                MakePropertiesFromStrings(
                    new string[][] {
                        new string[] {
                            "r2",
                            "B"
                        }
                    }));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[1].AssertOneGetNewAndReset(), new object[] {"B"});
        }
        public static void RunAssertionCaseStatic(EPServiceProvider epService) {
            var listeners = SupportUpdateListener.MakeListeners(5);
            var stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeOne");
            stmt.Events += listeners[0].Update;
            stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeTwo");
            stmt.Events += listeners[1].Update;
            stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeThree");
            stmt.Events += listeners[2].Update;
            stmt = epService.EPAdministrator.CreateEPL("select * from TestTypeFour");
            stmt.Events += listeners[3].Update;

            // static senders
            var sender = epService.EPRuntime.GetEventSender("TestTypeOne");
            sender.SendEvent(MakeProperties(new string[][] { new[] { "r1", "A"}, new[] { "t1", "B"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[0].AssertOneGetNewAndReset(), new object[] {"A", "B"});
            Assert.IsFalse(listeners[3].IsInvoked || listeners[1].IsInvoked || listeners[2].IsInvoked);

            sender = epService.EPRuntime.GetEventSender("TestTypeTwo");
            sender.SendEvent(MakeProperties(new string[][] { new[] { "r2", "C"}, new[] { "t2", "D"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[1].AssertOneGetNewAndReset(), new object[] {"C", "D"});
            Assert.IsFalse(listeners[3].IsInvoked || listeners[0].IsInvoked || listeners[2].IsInvoked);

            sender = epService.EPRuntime.GetEventSender("TestTypeThree");
            sender.SendEvent(MakeProperties(new string[][] { new[] { "r3", "E"}, new[] { "t3", "F"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[2].AssertOneGetNewAndReset(), new object[] {"E", "F"});
            Assert.IsFalse(listeners[3].IsInvoked || listeners[1].IsInvoked || listeners[0].IsInvoked);

            sender = epService.EPRuntime.GetEventSender("TestTypeFour");
            sender.SendEvent(MakeProperties(new string[][] { new[] { "r2", "G"}, new[] { "t4", "H"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[3].AssertOneGetNewAndReset(), new object[] {"G", "H"});
            Assert.IsFalse(listeners[0].IsInvoked || listeners[1].IsInvoked || listeners[2].IsInvoked);

            // dynamic sender - decides on event type thus a particular update listener should see the event
            var uriList = new[] {new Uri("type://properties/test1"), new Uri("type://properties/test2")};
            var dynamicSender = epService.EPRuntime.GetEventSender(uriList);
            dynamicSender.SendEvent(MakeProperties(new string[][] { new[] { "r3", "I"}, new[] { "t3", "J"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[2].AssertOneGetNewAndReset(), new object[] {"I", "J"});
            dynamicSender.SendEvent(MakeProperties(new string[][] { new[] { "r1", "K"}, new[] { "t1", "L"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[0].AssertOneGetNewAndReset(), new object[] {"K", "L"});
            dynamicSender.SendEvent(MakeProperties(new string[][] { new[] { "r2", "M"}, new[] { "t2", "N"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[1].AssertOneGetNewAndReset(), new object[] {"M", "N"});
            dynamicSender.SendEvent(MakeProperties(new string[][] {new []{"r2", "O"}, new[] { "t4", "P"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[3].AssertOneGetNewAndReset(), new object[] {"O", "P"});
            dynamicSender.SendEvent(MakeProperties(new string[][] { new[] { "r2", "O"}, new[] { "t3", "P"}}));
            AssertNoneReceived(listeners);

            uriList = new[] {new Uri("type://properties/test2")};
            dynamicSender = epService.EPRuntime.GetEventSender(uriList);
            dynamicSender.SendEvent(MakeProperties(new string[][] { new[] { "r1", "I"}, new[] { "t1", "J"}}));
            AssertNoneReceived(listeners);
            dynamicSender.SendEvent(MakeProperties(new string[][] { new[] { "r2", "Q"}, new[] { "t2", "R"}}));
            EPAssertionUtil.AssertAllPropsSortedByName(listeners[1].AssertOneGetNewAndReset(), new object[] {"Q", "R"});
        }
        private void RunAssertionAddRemoveStmts(EPServiceProvider epService)
        {
            string      stmtSelectText = "insert into ABCStream select * from SupportBean";
            EPStatement stmtSelect     = epService.EPAdministrator.CreateEPL(stmtSelectText);
            var         listener       = new SupportUpdateListener();

            stmtSelect.Events += listener.Update;

            string      stmtOneText  = "@Drop select * from SupportBean where IntPrimitive = 1";
            EPStatement statementOne = epService.EPAdministrator.CreateEPL(stmtOneText);

            SupportUpdateListener[] listeners = SupportUpdateListener.MakeListeners(10);
            statementOne.Events += listeners[0].Update;

            string      stmtTwoText  = "@Drop select * from SupportBean where IntPrimitive = 2";
            EPStatement statementTwo = epService.EPAdministrator.CreateEPL(stmtTwoText);

            statementTwo.Events += listeners[1].Update;

            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.IsFalse(listener.IsInvoked);
            AssertReceivedSingle(listeners, 0, "E1");

            epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            Assert.IsFalse(listener.IsInvoked);
            AssertReceivedSingle(listeners, 1, "E2");

            epService.EPRuntime.SendEvent(new SupportBean("E3", 1));
            Assert.IsFalse(listener.IsInvoked);
            AssertReceivedSingle(listeners, 0, "E3");

            epService.EPRuntime.SendEvent(new SupportBean("E4", 3));
            Assert.AreEqual("E4", listener.AssertOneGetNewAndReset().Get("TheString"));
            AssertReceivedNone(listeners);

            string      stmtThreeText  = "@Drop select * from SupportBean where IntPrimitive = 3";
            EPStatement statementThree = epService.EPAdministrator.CreateEPL(stmtThreeText);

            statementThree.Events += listeners[2].Update;

            epService.EPRuntime.SendEvent(new SupportBean("E5", 3));
            Assert.IsFalse(listener.IsInvoked);
            AssertReceivedSingle(listeners, 2, "E5");

            epService.EPRuntime.SendEvent(new SupportBean("E6", 1));
            Assert.IsFalse(listener.IsInvoked);
            AssertReceivedSingle(listeners, 0, "E6");

            statementOne.Dispose();
            epService.EPRuntime.SendEvent(new SupportBean("E7", 1));
            Assert.AreEqual("E7", listener.AssertOneGetNewAndReset().Get("TheString"));
            AssertReceivedNone(listeners);

            string      stmtSelectTextTwo = "@Priority(50) select * from SupportBean";
            EPStatement stmtSelectTwo     = epService.EPAdministrator.CreateEPL(stmtSelectTextTwo);
            var         listenerTwo       = new SupportUpdateListener();

            stmtSelectTwo.Events += listenerTwo.Update;

            epService.EPRuntime.SendEvent(new SupportBean("E8", 1));
            Assert.AreEqual("E8", listener.AssertOneGetNewAndReset().Get("TheString"));
            Assert.AreEqual("E8", listenerTwo.AssertOneGetNewAndReset().Get("TheString"));
            AssertReceivedNone(listeners);

            epService.EPRuntime.SendEvent(new SupportBean("E9", 2));
            Assert.IsFalse(listener.IsInvoked);
            AssertReceivedSingle(listeners, 1, "E9");

            epService.EPAdministrator.DestroyAllStatements();
        }