예제 #1
0
        public void TestEvalEvents()
        {
            for (int i = 0; i < _events.Count; i++)
            {
                var matchList = new List <FilterHandle>();
                _filterService.Evaluate(_events[i], matchList);
                foreach (FilterHandle match in matchList)
                {
                    var handle = (SupportFilterHandle)match;
                    handle.MatchFound(_events[i], null);
                }

                int[] matches = _matchesExpected[i];

                for (int j = 0; j < matches.Length; j++)
                {
                    SupportFilterHandle callback = _filterCallbacks[j];

                    if (matches[j] != callback.GetAndResetCountInvoked())
                    {
                        Log.Debug(".testEvalEvents Match failed, theEvent=" + _events[i].Underlying);
                        Log.Debug(".testEvalEvents Match failed, eventNumber=" + i + " index=" + j);
                        Assert.Fail();
                    }
                }
            }
        }
예제 #2
0
        public void TestActiveCallbackRemove()
        {
            var spec        = SupportFilterSpecBuilder.Build(_eventTypeOne, new Object[0]).GetValueSet(null, null, null);
            var callbackTwo = new SupportFilterHandle();

            // callback that removes another matching filter spec callback
            Atomic <FilterServiceEntry> filterServiceEntryOne = new Atomic <FilterServiceEntry>();
            FilterHandleCallback        callbackOne           = new ProxyFilterHandleCallback
            {
                ProcStatementId = () => "",
                ProcIsSubselect = () => false,
                ProcMatchFound  = (e, allStmtMatches) =>
                {
                    Log.Debug(".matchFound Removing callbackTwo");
                    _filterService.Remove(callbackTwo, filterServiceEntryOne.Value);
                }
            };

            FilterServiceEntry filterServiceEntry = _filterService.Add(spec, callbackOne);

            filterServiceEntryOne.Set(filterServiceEntry);
            _filterService.Add(spec, callbackTwo);

            // send event
            var theEvent = MakeTypeOneEvent(1, "HELLO", false, 1);
            var matches  = new List <FilterHandle>();

            _filterService.Evaluate(theEvent, matches);
            foreach (FilterHandle match in matches)
            {
                var handle = (FilterHandleCallback)match;
                handle.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.AreEqual(1, callbackTwo.GetAndResetCountInvoked());
        }