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"}); }
private void RunAssertionCaseStatic(EPServiceProvider epService) { EPStatement 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 EventSender sender = epService.EPRuntime.GetEventSender("TestTypeOne"); sender.SendEvent(MakeProperties(new String[][] { new String[] { "r1", "A" }, new String[] { "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 String[] { "r2", "C" }, new String[] { "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 String[] { "r3", "E" }, new String[] { "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 String[] { "r2", "G" }, new String[] { "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 Uri[] uriList = new Uri[] { new Uri("type://properties/test1"), new Uri("type://properties/test2") }; EventSender dynamicSender = epService.EPRuntime.GetEventSender(uriList); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r3", "I" }, new String[] { "t3", "J" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[2].AssertOneGetNewAndReset(), new Object[] { "I", "J" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r1", "K" }, new String[] { "t1", "L" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[0].AssertOneGetNewAndReset(), new Object[] { "K", "L" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "M" }, new String[] { "t2", "Count" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[1].AssertOneGetNewAndReset(), new Object[] { "M", "Count" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "O" }, new String[] { "t4", "P" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[3].AssertOneGetNewAndReset(), new Object[] { "O", "P" }); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "O" }, new String[] { "t3", "P" } })); AssertNoneReceived(); uriList = new Uri[] { new Uri("type://properties/test2") }; dynamicSender = epService.EPRuntime.GetEventSender(uriList); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r1", "I" }, new String[] { "t1", "J" } })); AssertNoneReceived(); dynamicSender.SendEvent(MakeProperties(new String[][] { new String[] { "r2", "Q" }, new String[] { "t2", "R" } })); EPAssertionUtil.AssertAllPropsSortedByName(_listeners[1].AssertOneGetNewAndReset(), new Object[] { "Q", "R" }); }