public void TestEvalEvents() { for (var i = 0; i < events.Count; i++) { IList <FilterHandle> matchList = new List <FilterHandle>(); filterService.Evaluate(events[i], (ICollection <FilterHandle>)matchList, (ExprEvaluatorContext)null); foreach (var match in matchList) { var handle = (SupportFilterHandle)match; handle.MatchFound(events[i], null); } var matches = matchesExpected[i]; for (var j = 0; j < matches.Length; j++) { SupportFilterHandle callback = filterCallbacks[j]; if (matches[j] != callback.GetAndResetCountInvoked()) { log.Debug(".testEvalEvents Match failed, event=" + events[i].Underlying); log.Debug(".testEvalEvents Match failed, eventNumber=" + i + " index=" + j); Assert.IsTrue(false); } } } }
public void TestActiveCallbackRemove() { var spec = SupportFilterSpecBuilder.Build(eventTypeOne, new object[0]).GetValueSet(null, null, null, null); var callbackTwo = new SupportFilterHandle(); // callback that removes another matching filter spec callback var callbackOne = new MySupportFilterHandle( filterService, callbackTwo, eventTypeOne, spec); filterService.Add(eventTypeOne, spec, callbackOne); filterService.Add(eventTypeOne, spec, callbackTwo); // send event var theEvent = MakeTypeOneEvent(1, "HELLO", false, 1); var matches = new List <FilterHandle>(); filterService.Evaluate(theEvent, (ICollection <FilterHandle>)matches, (ExprEvaluatorContext)null); foreach (var match in matches) { ((FilterHandleCallback)match).MatchFound(theEvent, null); } // Callback two MUST be invoked, was removed by callback one, but since the // callback invocation order should not matter, the second one MUST also execute Assert.That(callbackTwo.GetAndResetCountInvoked(), Is.EqualTo(1)); }