public void TestFlow()
        {
            var indexEvents = SupportEventBeanFactory.MakeEvents(new String[] { "a1", "a2" });

            _index.Add(indexEvents);

            var lookupEvents = SupportEventBeanFactory.MakeMarketDataEvents(new String[] { "a2", "a3" });

            var result  = new List <EventBean[]>();
            var prefill = new EventBean[] { lookupEvents[0], null };

            _exec.Process(lookupEvents[0], prefill, result, null);

            // Test lookup found 1 row
            Assert.AreEqual(1, result.Count);
            var events = result.FirstOrDefault();

            Assert.AreSame(indexEvents[1], events[1]);
            Assert.AreSame(lookupEvents[0], events[0]);

            // Test lookup found no rows
            result.Clear();
            _exec.Process(lookupEvents[1], prefill, result, null);
            Assert.AreEqual(0, result.Count);
        }
        public void TestFlow()
        {
            EventBean[]        lookupEvents = SupportEventBeanFactory.MakeMarketDataEvents(new String[] { "a2" });
            List <EventBean[]> result       = new List <EventBean[]>();

            EventBean[] prefill = new EventBean[] { lookupEvents[0], null };

            // Test lookup on empty index, expect 1 row
            exec.Process(lookupEvents[0], prefill, result, null);
            Assert.AreEqual(1, result.Count);
            EventBean[] events = result.FirstOrDefault();
            Assert.IsNull(events[1]);
            Assert.AreSame(lookupEvents[0], events[0]);
            result.Clear();

            // Test lookup on filled index, expect row2
            EventBean[] indexEvents = SupportEventBeanFactory.MakeEvents(new String[] { "a1", "a2" });
            index.Add(indexEvents);
            exec.Process(lookupEvents[0], prefill, result, null);
            Assert.AreEqual(2, result.Count);

            IEnumerator <EventBean[]> it = result.GetEnumerator();

            events = it.Advance();
            Assert.AreSame(lookupEvents[0], events[0]);
            Assert.IsTrue((indexEvents[0] == events[1]) || (indexEvents[1] == events[1]));

            events = it.Advance();
            Assert.AreSame(lookupEvents[0], events[0]);
            Assert.IsTrue((indexEvents[0] == events[1]) || (indexEvents[1] == events[1]));
        }
        public void TestFlow()
        {
            EventBean[] oldDataOne = SupportEventBeanFactory.MakeEvents(new String[] { "a" });
            EventBean[] newDataOne = SupportEventBeanFactory.MakeEvents(new String[] { "b" });
            EventBean[] oldDataTwo = SupportEventBeanFactory.MakeEvents(new String[] { "c" });
            EventBean[] newDataTwo = SupportEventBeanFactory.MakeEvents(new String[] { "d" });

            _bufferViewOne.Update(newDataOne, oldDataOne);
            _dispatchable.Execute();
            Assert.AreEqual(1, _joinExecutionStrategy.GetLastNewDataPerStream()[0].Length);
            Assert.AreSame(newDataOne[0], _joinExecutionStrategy.GetLastNewDataPerStream()[0][0]);
            Assert.AreSame(oldDataOne[0], _joinExecutionStrategy.GetLastOldDataPerStream()[0][0]);
            Assert.IsNull(_joinExecutionStrategy.GetLastNewDataPerStream()[1]);
            Assert.IsNull(_joinExecutionStrategy.GetLastOldDataPerStream()[1]);

            _bufferViewOne.Update(newDataTwo, oldDataTwo);
            _bufferViewTwo.Update(newDataOne, oldDataOne);
            _dispatchable.Execute();
            Assert.AreEqual(1, _joinExecutionStrategy.GetLastNewDataPerStream()[0].Length);
            Assert.AreEqual(1, _joinExecutionStrategy.GetLastNewDataPerStream()[1].Length);
            Assert.AreSame(newDataTwo[0], _joinExecutionStrategy.GetLastNewDataPerStream()[0][0]);
            Assert.AreSame(oldDataTwo[0], _joinExecutionStrategy.GetLastOldDataPerStream()[0][0]);
            Assert.AreSame(newDataOne[0], _joinExecutionStrategy.GetLastNewDataPerStream()[1][0]);
            Assert.AreSame(oldDataOne[0], _joinExecutionStrategy.GetLastOldDataPerStream()[1][0]);
        }
        public void SetUp()
        {
            _indexedEventOne = SupportEventBeanFactory.MakeEvents(new String[] { "s1_1", "s1_2" });
            _indexedEventTwo = SupportEventBeanFactory.MakeEvents(new String[] { "s2_1", "s2_2" });

            _newEventOne = SupportEventBeanFactory.MakeEvents(new String[] { "s1_3" });
            _newEventTwo = SupportEventBeanFactory.MakeEvents(new String[] { "s2_3" });

            _indexLeft = new UnindexedEventTableImpl(1);
            _indexLeft.Add(_indexedEventOne);
            _indexRight = new UnindexedEventTableImpl(1);
            _indexRight.Add(_indexedEventTwo);

            var queryStrategies = new QueryStrategy[2];
            var lookupLeft      = new TableLookupExecNode(1, new FullTableScanLookupStrategy(_indexRight));
            var lookupRight     = new TableLookupExecNode(0, new FullTableScanLookupStrategy(_indexLeft));

            queryStrategies[0] = new ExecNodeQueryStrategy(0, 2, lookupLeft);
            queryStrategies[1] = new ExecNodeQueryStrategy(1, 2, lookupRight);

            var indexes = new IDictionary <TableLookupIndexReqKey, EventTable> [2];

            indexes[0] = new NullableDictionary <TableLookupIndexReqKey, EventTable>();
            indexes[1] = new NullableDictionary <TableLookupIndexReqKey, EventTable>();
            indexes[0].Put(new TableLookupIndexReqKey("idxLeft"), _indexLeft);
            indexes[1].Put(new TableLookupIndexReqKey("idxLeft"), _indexRight);

            _joinSetComposerImpl = new JoinSetComposerImpl(true, indexes, queryStrategies, false, null, true);
        }
        public void TestFlow()
        {
            UnindexedEventTable rep = new UnindexedEventTableImpl(1);

            EventBean[] addOne = SupportEventBeanFactory.MakeEvents(new String[] { "a", "b" });
            rep.Add(addOne);
            rep.Remove(new EventBean[] { addOne[0] });
        }
Exemple #6
0
        public void TestEvaluate()
        {
            for (var i = 0; i < _existsNodes.Length; i++)
            {
                _existsNodes[i].Validate(SupportExprValidationContextFactory.MakeEmpty(container));
            }

            Assert.AreEqual(false, _existsNodes[0].Evaluate(new EventBean[3], false, null));
            Assert.AreEqual(false, _existsNodes[1].Evaluate(new EventBean[3], false, null));

            EventBean[] events = { SupportEventBeanFactory.MakeEvents(supportEventTypeFactory, new string[1])[0] };
            Assert.AreEqual(false, _existsNodes[0].Evaluate(events, false, null));
            Assert.AreEqual(true, _existsNodes[1].Evaluate(events, false, null));
        }
Exemple #7
0
        public void TestWithSet()
        {
            EventBean[][] testEvents = new EventBean[][] {
                SupportEventBeanFactory.MakeEvents(new String[] { "a", "b" }),
                SupportEventBeanFactory.MakeEvents(new String[] { "a" }),
                SupportEventBeanFactory.MakeEvents(new String[] { "a", "b", "c" }),
                SupportEventBeanFactory.MakeEvents(new String[] { "a", "b" }),
            };

            ICollection <MultiKeyUntyped> mapSet = new HashSet <MultiKeyUntyped>();

            // Test contains
            mapSet.Add(new MultiKeyUntyped(testEvents[0]));
            Assert.IsTrue(mapSet.Contains(new MultiKeyUntyped(testEvents[0])));
            Assert.IsFalse(mapSet.Contains(new MultiKeyUntyped(testEvents[1])));
            Assert.IsFalse(mapSet.Contains(new MultiKeyUntyped(testEvents[2])));
            Assert.IsFalse(mapSet.Contains(new MultiKeyUntyped(testEvents[3])));

            // Test unique
            mapSet.Add(new MultiKeyUntyped(testEvents[0]));
            Assert.AreEqual(1, mapSet.Count);

            mapSet.Add(new MultiKeyUntyped(testEvents[1]));
            mapSet.Add(new MultiKeyUntyped(testEvents[2]));
            mapSet.Add(new MultiKeyUntyped(testEvents[3]));
            Assert.AreEqual(4, mapSet.Count);

            mapSet.Remove(new MultiKeyUntyped(testEvents[0]));
            Assert.AreEqual(3, mapSet.Count);
            Assert.IsFalse(mapSet.Contains(new MultiKeyUntyped(testEvents[0])));

            mapSet.Remove(new MultiKeyUntyped(testEvents[1]));
            mapSet.Remove(new MultiKeyUntyped(testEvents[2]));
            mapSet.Remove(new MultiKeyUntyped(testEvents[3]));
            Assert.AreEqual(0, mapSet.Count);
        }
Exemple #8
0
        public void TestUpdate()
        {
            // Test all evaluate to true (ie. all pass the filter)
            EventBean[] oldEvents = SupportEventBeanFactory.MakeEvents(new [] { true, true });
            EventBean[] newEvents = SupportEventBeanFactory.MakeEvents(new [] { true, true });
            _filterExprViewAdapter.Update(newEvents, oldEvents);

            Assert.AreEqual(newEvents, _childView.LastNewData);
            Assert.AreEqual(oldEvents, _childView.LastOldData);
            _childView.Reset();

            // Test all evaluate to false (ie. none pass the filter)
            oldEvents = SupportEventBeanFactory.MakeEvents(new [] { false, false });
            newEvents = SupportEventBeanFactory.MakeEvents(new [] { false, false });
            _filterExprViewAdapter.Update(newEvents, oldEvents);

            Assert.IsFalse(_childView.GetAndClearIsInvoked());  // Should not be invoked if no events
            Assert.IsNull(_childView.LastNewData);
            Assert.IsNull(_childView.LastOldData);

            // Test some pass through the filter
            oldEvents = SupportEventBeanFactory.MakeEvents(new [] { false, true, false });
            newEvents = SupportEventBeanFactory.MakeEvents(new [] { true, false, true });
            _filterExprViewAdapter.Update(newEvents, oldEvents);

            Assert.NotNull(_childView.LastNewData);
            Assert.NotNull(_childView.LastOldData);

            // ReSharper disable PossibleNullReferenceException
            Assert.AreEqual(2, _childView.LastNewData.Length);
            Assert.AreSame(newEvents[0], _childView.LastNewData[0]);
            Assert.AreSame(newEvents[2], _childView.LastNewData[1]);
            Assert.AreEqual(1, _childView.LastOldData.Length);
            Assert.AreSame(oldEvents[1], _childView.LastOldData[0]);
            // ReSharper restore PossibleNullReferenceException
        }
Exemple #9
0
        public void TestWithSet()
        {
            EventBean[][] testEvents = new EventBean[][]{
                    SupportEventBeanFactory.MakeEvents(supportEventTypeFactory, new string[]{"a", "b"}),
                    SupportEventBeanFactory.MakeEvents(supportEventTypeFactory, new string[]{"a"}),
                    SupportEventBeanFactory.MakeEvents(supportEventTypeFactory, new string[]{"a", "b", "c"}),
                    SupportEventBeanFactory.MakeEvents(supportEventTypeFactory, new string[]{"a", "b"}),
            };

            ISet<HashableMultiKey> mapSet = new HashSet<HashableMultiKey>();

            // Test contains
            mapSet.Add(new HashableMultiKey(testEvents[0]));
            Assert.IsTrue(mapSet.Contains(new HashableMultiKey(testEvents[0])));
            Assert.IsFalse(mapSet.Contains(new HashableMultiKey(testEvents[1])));
            Assert.IsFalse(mapSet.Contains(new HashableMultiKey(testEvents[2])));
            Assert.IsFalse(mapSet.Contains(new HashableMultiKey(testEvents[3])));

            // Test unique
            mapSet.Add(new HashableMultiKey(testEvents[0]));
            Assert.AreEqual(1, mapSet.Count);

            mapSet.Add(new HashableMultiKey(testEvents[1]));
            mapSet.Add(new HashableMultiKey(testEvents[2]));
            mapSet.Add(new HashableMultiKey(testEvents[3]));
            Assert.AreEqual(4, mapSet.Count);

            mapSet.Remove(new HashableMultiKey(testEvents[0]));
            Assert.AreEqual(3, mapSet.Count);
            Assert.IsFalse(mapSet.Contains(new HashableMultiKey(testEvents[0])));

            mapSet.Remove(new HashableMultiKey(testEvents[1]));
            mapSet.Remove(new HashableMultiKey(testEvents[2]));
            mapSet.Remove(new HashableMultiKey(testEvents[3]));
            Assert.AreEqual(0, mapSet.Count);
        }
Exemple #10
0
 public void SetUp()
 {
     _list   = new OneEventCollection();
     _events = SupportEventBeanFactory.MakeEvents(new [] { "1", "2", "3", "4" });
 }
 public void SetUp()
 {
     list   = new OneEventCollection();
     events = SupportEventBeanFactory.MakeEvents(
         supportEventTypeFactory, new string[] { "1", "2", "3", "4" });
 }