Пример #1
0
        public void SetUp()
        {
            _container = SupportContainer.Reset();
            SupportLegacyBean testEvent = new SupportLegacyBean("a");

            _unitTestBean = SupportEventBeanFactory.CreateObject(testEvent);
        }
Пример #2
0
        private EventBean MakeEvent(double doublePrimitive)
        {
            SupportBean theEvent = new SupportBean();

            theEvent.DoublePrimitive = doublePrimitive;
            return(SupportEventBeanFactory.CreateObject(theEvent));
        }
Пример #3
0
        protected EventBean MakeEvent(int intPrimitive)
        {
            SupportBean theEvent = new SupportBean();

            theEvent.IntPrimitive = intPrimitive;
            return(SupportEventBeanFactory.CreateObject(supportEventTypeFactory, theEvent));
        }
Пример #4
0
        private EventBean[] MakeEvent(string stringValue)
        {
            var theEvent = new SupportBean();

            theEvent.TheString = stringValue;
            return(new[] { SupportEventBeanFactory.CreateObject(supportEventTypeFactory, theEvent) });
        }
Пример #5
0
        public void SetUp()
        {
            _container   = SupportContainer.Reset();
            _lockFactory = new FilterServiceGranularLockFactoryReentrant(
                _container.Resolve <IReaderWriterLockManager>());

            var testBean = new SupportBean();

            testBean.IntPrimitive    = 50;
            testBean.DoublePrimitive = 0.5;
            testBean.TheString       = "jack";
            testBean.LongPrimitive   = 10;
            testBean.ShortPrimitive  = (short)20;

            _eventBean = SupportEventBeanFactory.CreateObject(testBean);
            _eventType = _eventBean.EventType;

            _matches = new List <FilterHandle>();

            // Allocate a couple of callbacks
            _testFilterCallback = new SupportFilterHandle[20];
            for (var i = 0; i < _testFilterCallback.Length; i++)
            {
                _testFilterCallback[i] = new SupportFilterHandle();
            }
        }
        public void TestAdd()
        {
            // Add event without these properties should fail
            EventBean theEvent = SupportEventBeanFactory.CreateObject(new SupportBean_A("d"));
            try
            {
                _index.Add(new[] {theEvent});
                Assert.Fail();
            }
            catch (PropertyAccessException ex)
            {
                // Expected
            }

            // Add null should fail
            try
            {
                _index.Add(new EventBean[] {null});
                Assert.Fail();
            }
            catch (PropertyAccessException ex)
            {
                // Expected
            }
        }
Пример #7
0
        public void TestGetIterableListMapContained()
        {
            SupportBeanIterablePropsContainer eventIterableContained = SupportBeanIterablePropsContainer.MakeDefaultBean();
            EventBean eventBean = SupportEventBeanFactory.CreateObject(eventIterableContained);

            Assert.AreEqual(typeof(IEnumerable <SupportBeanIterableProps.SupportBeanSpecialGetterNested>), eventBean.EventType.GetPropertyType("Contained.IterableNested"));
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), eventBean.EventType.GetPropertyType("Contained.IterableNested[0]"));
            Assert.AreEqual(typeof(IEnumerable <int?>), eventBean.EventType.GetPropertyType("Contained.IterableInteger"));
            Assert.AreEqual(typeof(int?), eventBean.EventType.GetPropertyType("Contained.IterableInteger[0]"));
            Assert.AreEqual(typeof(IList <SupportBeanIterableProps.SupportBeanSpecialGetterNested>), eventBean.EventType.GetPropertyType("Contained.ListNested"));
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), eventBean.EventType.GetPropertyType("Contained.ListNested[0]"));
            Assert.AreEqual(typeof(IList <int?>), eventBean.EventType.GetPropertyType("Contained.ListInteger"));
            Assert.AreEqual(typeof(int?), eventBean.EventType.GetPropertyType("Contained.ListInteger[0]"));
            Assert.AreEqual(typeof(IDictionary <string, SupportBeanIterableProps.SupportBeanSpecialGetterNested>), eventBean.EventType.GetPropertyType("Contained.MapNested"));
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), eventBean.EventType.GetPropertyType("Contained.MapNested('a')"));
            Assert.AreEqual(typeof(IDictionary <string, int>), eventBean.EventType.GetPropertyType("Contained.MapInteger"));
            Assert.AreEqual(typeof(int), eventBean.EventType.GetPropertyType("Contained.MapInteger('a')"));

            AssertNestedElement(eventBean, "Contained.MapNested('a')", "MN1");    // note that property descriptors do not indicate Map-values are fragments
            AssertNestedElement(eventBean, "Contained.MapNested('b')", "MN2");
            AssertNestedElement(eventBean, "Contained.ListNested[0]", "LN1");
            AssertNestedElement(eventBean, "Contained.ListNested[1]", "LN2");
            AssertNestedElement(eventBean, "Contained.IterableNested[0]", "IN1");
            AssertNestedElement(eventBean, "Contained.IterableNested[1]", "IN2");
            AssertNestedCollection(eventBean, "Contained.IterableNested", "I");
            AssertNestedCollection(eventBean, "Contained.ListNested", "L");

            Assert.IsNull(eventBean.EventType.GetFragmentType("Contained.IterableInteger"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("Contained.ListInteger"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("Contained.IterableInteger[0]"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("Contained.ListInteger[0]"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("Contained.MapNested"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("Contained.MapInteger"));
        }
Пример #8
0
        public void TestSetBehavior()
        {
            ISet<InterchangeablePair<EventBean, EventBean>> eventPairs = new HashSet<InterchangeablePair<EventBean, EventBean>>();

            EventBean[] events = new EventBean[4];
            for (int i = 0; i < events.Length; i++)
            {
                events[i] = SupportEventBeanFactory.CreateObject(
                    supportEventTypeFactory, new SupportBean("E" + i, i));
            }

            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[0], events[1]));
            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[0], events[2]));
            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[1], events[2]));
            Assert.AreEqual(3, eventPairs.Count);

            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[0], events[1]));
            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[1], events[2]));
            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[2], events[0]));
            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[2], events[1]));
            eventPairs.Add(new InterchangeablePair<EventBean, EventBean>(events[1], events[0]));
            Assert.AreEqual(3, eventPairs.Count);

            Assert.IsTrue(eventPairs.Contains(new InterchangeablePair<EventBean, EventBean>(events[1], events[0])));
            Assert.IsFalse(eventPairs.Contains(new InterchangeablePair<EventBean, EventBean>(events[3], events[0])));
            Assert.IsTrue(eventPairs.Contains(new InterchangeablePair<EventBean, EventBean>(events[1], events[2])));
            Assert.IsTrue(eventPairs.Contains(new InterchangeablePair<EventBean, EventBean>(events[2], events[0])));

            eventPairs.Remove(new InterchangeablePair<EventBean, EventBean>(events[2], events[0]));
            Assert.IsFalse(eventPairs.Contains(new InterchangeablePair<EventBean, EventBean>(events[2], events[0])));
            eventPairs.Remove(new InterchangeablePair<EventBean, EventBean>(events[1], events[2]));
            eventPairs.Remove(new InterchangeablePair<EventBean, EventBean>(events[1], events[0]));

            Assert.IsTrue(eventPairs.IsEmpty());
        }
Пример #9
0
        private EventBean[] MakeEvent(String stringValue)
        {
            SupportBean theEvent = new SupportBean();

            theEvent.TheString = stringValue;
            return(new EventBean[] { SupportEventBeanFactory.CreateObject(theEvent) });
        }
Пример #10
0
        public void TestGetValueSet()
        {
            IList <FilterSpecParam> parameters = SupportFilterSpecBuilder.BuildList(_eventType, new Object[]
                                                                                    { "IntPrimitive", FilterOperator.EQUAL, 2 });
            var numberCoercer = CoercerFactory.GetCoercer(typeof(int), typeof(double));

            parameters.Add(new FilterSpecParamEventProp(MakeLookupable("DoubleBoxed"), FilterOperator.EQUAL, "asName", "DoublePrimitive", false, numberCoercer, typeof(double?), "Test"));
            FilterSpecCompiled filterSpec = new FilterSpecCompiled(_eventType, "SupportBean", new IList <FilterSpecParam>[] { parameters }, null);

            SupportBean eventBean = new SupportBean();

            eventBean.DoublePrimitive = 999.999;
            EventBean       theEvent      = SupportEventBeanFactory.CreateObject(eventBean);
            MatchedEventMap matchedEvents = new MatchedEventMapImpl(new MatchedEventMapMeta(new String[] { "asName" }, false));

            matchedEvents.Add(0, theEvent);
            FilterValueSet valueSet = filterSpec.GetValueSet(matchedEvents, null, null);

            // Assert the generated filter value container
            Assert.AreSame(_eventType, valueSet.EventType);
            Assert.AreEqual(2, valueSet.Parameters[0].Length);

            // Assert the first param
            var param = valueSet.Parameters[0][0];

            Assert.AreEqual("IntPrimitive", param.Lookupable.Expression);
            Assert.AreEqual(FilterOperator.EQUAL, param.FilterOperator);
            Assert.AreEqual(2, param.FilterForValue);

            // Assert the second param
            param = (FilterValueSetParam)valueSet.Parameters[0][1];
            Assert.AreEqual("DoubleBoxed", param.Lookupable.Expression);
            Assert.AreEqual(FilterOperator.EQUAL, param.FilterOperator);
            Assert.AreEqual(999.999, param.FilterForValue);
        }
Пример #11
0
        protected internal static EventBean MakeEvent(int intPrimitive)
        {
            SupportBean theEvent = new SupportBean();

            theEvent.IntPrimitive = intPrimitive;
            return(SupportEventBeanFactory.CreateObject(theEvent));
        }
 private EventBean MakeBean(int intValue, String stringValue)
 {
     var bean = new SupportBean();
     bean.IntPrimitive = intValue;
     bean.TheString = stringValue;
     return SupportEventBeanFactory.CreateObject(bean);
 }
 private EventBean MakeEvent(int intPrimitive, int intBoxed)
 {
     var bean = new SupportBean();
     bean.IntPrimitive = intPrimitive;
     bean.IntBoxed = intBoxed;
     return SupportEventBeanFactory.CreateObject(bean);
 }
 public void SetUp()
 {
     _bean              = SupportBeanComplexProps.MakeDefaultBean();
     _event             = SupportEventBeanFactory.CreateObject(_bean);
     _getter            = MakeGetter(0);
     _getterOutOfBounds = MakeGetter(int.MaxValue);
 }
 public void SetUp()
 {
     bean              = SupportBeanComplexProps.MakeDefaultBean();
     theEvent          = SupportEventBeanFactory.CreateObject(supportEventTypeFactory, bean);
     getter            = MakeGetter(0);
     getterOutOfBounds = MakeGetter(Int32.MaxValue);
 }
        public EventBean MakeEvent()
        {
            var theEvent = SupportEventBeanFactory.CreateObject(
                SupportEventTypeFactory.GetInstance(_container), new SupportBean());

            return(theEvent);
        }
Пример #17
0
        public void TestGetGetter()
        {
            SupportBean nestedSupportBean = new SupportBean();

            nestedSupportBean.IntPrimitive = 100;
            SupportBeanComplexProps complexPropBean = SupportBeanComplexProps.MakeDefaultBean();

            Assert.AreEqual(null, _eventType.GetGetter("dummy"));

            Object[]  values    = new Object[] { 20, 20, "a", nestedSupportBean, complexPropBean, null };
            EventBean eventBean = new ObjectArrayEventBean(values, _eventType);

            Assert.AreEqual(20, _eventType.GetGetter("myInt").Get(eventBean));
            Assert.AreEqual(20, _eventType.GetGetter("myIntBoxed").Get(eventBean));
            Assert.AreEqual("a", _eventType.GetGetter("myString").Get(eventBean));
            Assert.AreEqual(nestedSupportBean, _eventType.GetGetter("mySupportBean").Get(eventBean));
            Assert.AreEqual(100, _eventType.GetGetter("mySupportBean.IntPrimitive").Get(eventBean));
            Assert.AreEqual("NestedValue", _eventType.GetGetter("myComplexBean.Nested.NestedValue").Get(eventBean));

            try
            {
                eventBean = SupportEventBeanFactory.CreateObject(new Object());
                _eventType.GetGetter("myInt").Get(eventBean);
                Assert.IsTrue(false);
            }
            catch (InvalidCastException ex)
            {
            }
        }
Пример #18
0
        private EventBean[] MakeEvent(int intPrimitive)
        {
            var theEvent = new SupportBean();

            theEvent.IntPrimitive = intPrimitive;
            return(new[] { SupportEventBeanFactory.CreateObject(supportEventTypeFactory, theEvent) });
        }
Пример #19
0
        public void TestNodeMatching()
        {
            SupportBeanSimple eventObject = new SupportBeanSimple("DepositEvent_1", 1);
            EventBean         eventBean   = SupportEventBeanFactory.CreateObject(eventObject);

            FilterHandle expr = new SupportFilterHandle();

            _testNode.Add(expr);

            // Check matching without an index node
            List <FilterHandle> matches = new List <FilterHandle>();

            _testNode.MatchEvent(eventBean, matches);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(expr, matches[0]);
            matches.Clear();

            // Create, add and populate an index node
            FilterParamIndexBase index = new FilterParamIndexEquals(
                MakeLookupable("MyString", eventBean.EventType), ReaderWriterLockManager.CreateDefaultLock());

            _testNode.Add(index);
            index["DepositEvent_1"] = _testEvaluator;

            // Verify matcher instance stored in index is called
            _testNode.MatchEvent(eventBean, matches);

            Assert.IsTrue(_testEvaluator.GetAndResetCountInvoked() == 1);
            Assert.IsTrue(_testEvaluator.GetLastEvent() == eventBean);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(expr, matches[0]);
        }
Пример #20
0
        private static EventBean[] MakeEvent(int intPrimitive)
        {
            SupportBean theEvent = new SupportBean();

            theEvent.IntPrimitive = intPrimitive;
            return(new EventBean[] { SupportEventBeanFactory.CreateObject(theEvent) });
        }
Пример #21
0
        private static EventBean[] MakeEvent(String stringValue)
        {
            var theEvent = new SupportBean {
                TheString = stringValue
            };

            return(new[] { SupportEventBeanFactory.CreateObject(theEvent) });
        }
        public void SetUp()
        {
            _bean     = SupportBeanComplexProps.MakeDefaultBean();
            _theEvent = SupportEventBeanFactory.CreateObject(_bean);
            var method = typeof(SupportBeanComplexProps).GetMethod("GetIndexed", new Type[] { typeof(int) });

            _getter = new KeyedMethodPropertyGetter(method, 1, SupportEventAdapterService.Service);
        }
        public void SetUp()
        {
            bean     = new SupportLegacyBean(new string[] { "a", "b" });
            theEvent = SupportEventBeanFactory.CreateObject(supportEventTypeFactory, bean);

            getter            = MakeGetter(0);
            getterOutOfBounds = MakeGetter(Int32.MaxValue);
        }
Пример #24
0
        public void SetUp()
        {
            bean     = SupportBeanComplexProps.MakeDefaultBean();
            theEvent = SupportEventBeanFactory.CreateObject(supportEventTypeFactory, bean);
            var method = typeof(SupportBeanComplexProps).GetMethod("GetIndexed", new Type[] { typeof(int) });

            getter = new KeyedMethodPropertyGetter(method, 1, null, null);
        }
Пример #25
0
        private EventBean MakeEvent(int aInt, double aDouble)
        {
            var bean = new SupportBean();

            bean.IntPrimitive    = aInt;
            bean.DoublePrimitive = aDouble;
            return(SupportEventBeanFactory.CreateObject(bean));
        }
Пример #26
0
        public void TestLookup()
        {
            EventBean lookupEvent = SupportEventBeanFactory.CreateObject(new SupportBean());

            _strategy.Lookup(new[] { lookupEvent }, null, null);

            Assert.AreSame(lookupEvent, _supportQueryExecNode.LastPrefillPath[4]);
        }
Пример #27
0
        public void SetUp()
        {
            _bean  = new SupportLegacyBean(new[] { "a", "b" });
            _event = SupportEventBeanFactory.CreateObject(_bean);

            _getter            = MakeGetter(0);
            _getterOutOfBounds = MakeGetter(int.MaxValue);
        }
Пример #28
0
 public void SetUp()
 {
     _testEvaluator = new SupportEventEvaluator();
     _testBean      = new SupportBean();
     _testEventBean = SupportEventBeanFactory.CreateObject(_testBean);
     _testEventType = _testEventBean.EventType;
     _matchesList   = new List <FilterHandle>();
 }
Пример #29
0
        public void TestGetIterableListMap()
        {
            SupportBeanIterableProps eventComplex = SupportBeanIterableProps.MakeDefaultBean();
            EventBean eventBean = SupportEventBeanFactory.CreateObject(eventComplex);

            EventTypeAssertionUtil.AssertConsistency(eventBean);

            // generic interogation : iterable, List and Map
            Assert.AreEqual(typeof(IEnumerable <SupportBeanIterableProps.SupportBeanSpecialGetterNested>), eventBean.EventType.GetPropertyType("IterableNested"));
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), eventBean.EventType.GetPropertyType("IterableNested[0]"));
            Assert.AreEqual(typeof(IEnumerable <int?>), eventBean.EventType.GetPropertyType("IterableInteger"));
            Assert.AreEqual(typeof(int?), eventBean.EventType.GetPropertyType("IterableInteger[0]"));
            Assert.AreEqual(typeof(IList <SupportBeanIterableProps.SupportBeanSpecialGetterNested>), eventBean.EventType.GetPropertyType("ListNested"));
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), eventBean.EventType.GetPropertyType("ListNested[0]"));
            Assert.AreEqual(typeof(IList <int?>), eventBean.EventType.GetPropertyType("ListInteger"));
            Assert.AreEqual(typeof(int?), eventBean.EventType.GetPropertyType("ListInteger[0]"));
            Assert.AreEqual(typeof(IDictionary <string, SupportBeanIterableProps.SupportBeanSpecialGetterNested>), eventBean.EventType.GetPropertyType("MapNested"));
            Assert.AreEqual(typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), eventBean.EventType.GetPropertyType("MapNested('a')"));
            Assert.AreEqual(typeof(IDictionary <string, int>), eventBean.EventType.GetPropertyType("MapInteger"));
            Assert.AreEqual(typeof(int), eventBean.EventType.GetPropertyType("MapInteger('a')"));
            Assert.AreEqual(typeof(IEnumerable), eventBean.EventType.GetPropertyType("IterableUndefined"));
            Assert.AreEqual(typeof(IEnumerable <object>), eventBean.EventType.GetPropertyType("IterableObject"));
            Assert.AreEqual(typeof(Object), eventBean.EventType.GetPropertyType("IterableUndefined[0]"));
            Assert.AreEqual(typeof(Object), eventBean.EventType.GetPropertyType("IterableObject[0]"));

            Assert.AreEqual(new EventPropertyDescriptor("IterableNested", typeof(IEnumerable <SupportBeanIterableProps.SupportBeanSpecialGetterNested>), typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), false, false, true, false, true),
                            eventBean.EventType.GetPropertyDescriptor("IterableNested"));
            Assert.AreEqual(new EventPropertyDescriptor("IterableInteger", typeof(IEnumerable <int?>), typeof(int?), false, false, true, false, false),
                            eventBean.EventType.GetPropertyDescriptor("IterableInteger"));
            Assert.AreEqual(new EventPropertyDescriptor("ListNested", typeof(IList <SupportBeanIterableProps.SupportBeanSpecialGetterNested>), typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), false, false, true, false, true),
                            eventBean.EventType.GetPropertyDescriptor("ListNested"));
            Assert.AreEqual(new EventPropertyDescriptor("ListInteger", typeof(IList <int?>), typeof(int?), false, false, true, false, false),
                            eventBean.EventType.GetPropertyDescriptor("ListInteger"));
            Assert.AreEqual(new EventPropertyDescriptor("MapNested", typeof(IDictionary <string, SupportBeanIterableProps.SupportBeanSpecialGetterNested>), typeof(SupportBeanIterableProps.SupportBeanSpecialGetterNested), false, false, false, true, false),
                            eventBean.EventType.GetPropertyDescriptor("MapNested"));
            Assert.AreEqual(new EventPropertyDescriptor("MapInteger", typeof(IDictionary <string, int>), typeof(int), false, false, false, true, false),
                            eventBean.EventType.GetPropertyDescriptor("MapInteger"));
            Assert.AreEqual(new EventPropertyDescriptor("IterableUndefined", typeof(IEnumerable), typeof(object), false, false, true, false, false),
                            eventBean.EventType.GetPropertyDescriptor("IterableUndefined"));
            Assert.AreEqual(new EventPropertyDescriptor("IterableObject", typeof(IEnumerable <object>), typeof(object), false, false, true, false, false),
                            eventBean.EventType.GetPropertyDescriptor("IterableObject"));

            AssertNestedCollection(eventBean, "IterableNested", "I");
            AssertNestedCollection(eventBean, "ListNested", "L");
            AssertNestedElement(eventBean, "MapNested('a')", "MN1");    // note that property descriptors do not indicate Map-values are fragments
            AssertNestedElement(eventBean, "MapNested('b')", "MN2");
            AssertNestedElement(eventBean, "ListNested[0]", "LN1");
            AssertNestedElement(eventBean, "ListNested[1]", "LN2");
            AssertNestedElement(eventBean, "IterableNested[0]", "IN1");
            AssertNestedElement(eventBean, "IterableNested[1]", "IN2");

            Assert.IsNull(eventBean.EventType.GetFragmentType("IterableInteger"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("ListInteger"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("IterableInteger[0]"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("ListInteger[0]"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("MapNested"));
            Assert.IsNull(eventBean.EventType.GetFragmentType("MapInteger"));
        }
Пример #30
0
 public void SetUp()
 {
     _prop               = new SimpleProperty("SimpleProperty");
     _invalidPropMap     = new SimpleProperty("Mapped");
     _invalidPropIndexed = new SimpleProperty("Indexed");
     _invalidDummy       = new SimpleProperty("Dummy");
     _theEvent           = SupportEventBeanFactory.CreateObject(SupportBeanComplexProps.MakeDefaultBean());
     _eventType          = (BeanEventType)_theEvent.EventType;
 }