Esempio n. 1
0
        public void TestCopyView()
        {
            CorrelationView copied = (CorrelationView)_myView.CloneView();

            Assert.IsTrue(_myView.ExpressionX.Equals(copied.ExpressionX));
            Assert.IsTrue(_myView.ExpressionY.Equals(copied.ExpressionY));
        }
Esempio n. 2
0
        private void TryParameter(object[] parameters, string fieldNameX, string fieldNameY)
        {
            _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(parameters));
            _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null);
            CorrelationView view = (CorrelationView)_factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext());

            Assert.AreEqual(fieldNameX, ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(view.ExpressionX));
            Assert.AreEqual(fieldNameY, ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(view.ExpressionY));
        }
Esempio n. 3
0
        public void TestCanReuse()
        {
            factory.SetViewParameters(new ViewFactoryContext(null, 1, 1, null, null), TestViewSupport.ToExprListMD(new object[] { "Price", "Volume" }));
            factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null);
            Assert.IsFalse(factory.CanReuse(new FirstElementView(null)));
            EventType type = CorrelationView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1);

            Assert.IsFalse(factory.CanReuse(new CorrelationView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), SupportExprNodeFactory.MakeIdentNodeMD("Price"), type, null)));
            Assert.IsFalse(factory.CanReuse(new CorrelationView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Feed"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null)));
            Assert.IsTrue(factory.CanReuse(new CorrelationView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null)));
        }
Esempio n. 4
0
        public void SetUp()
        {
            // Set up sum view and a test child view
            EventType type = CorrelationView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1);
            CorrelationViewFactory factory = new CorrelationViewFactory();

            _myView = new CorrelationView(factory,
                                          SupportStatementContextFactory.MakeAgentInstanceContext(),
                                          SupportExprNodeFactory.MakeIdentNodeMD("Price"),
                                          SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null);

            _childView = new SupportBeanClassView(typeof(SupportMarketDataBean));
            _myView.AddView(_childView);
        }
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            ExprNode[] validated = ViewFactorySupport.Validate(ViewName, parentEventType, statementContext, _viewParameters, true);
            if (validated.Length < 2)
            {
                throw new ViewParameterException(ViewParamMessage);
            }
            if ((!validated[0].ExprEvaluator.ReturnType.IsNumeric()) || (!validated[1].ExprEvaluator.ReturnType.IsNumeric()))
            {
                throw new ViewParameterException(ViewParamMessage);
            }

            _expressionX = validated[0];
            _expressionY = validated[1];

            _additionalProps = StatViewAdditionalProps.Make(validated, 2, parentEventType);
            _eventType       = CorrelationView.CreateEventType(statementContext, _additionalProps, _streamNumber);
        }
        public bool CanReuse(View view)
        {
            if (!(view is CorrelationView))
            {
                return(false);
            }

            if (_additionalProps != null)
            {
                return(false);
            }

            CorrelationView other = (CorrelationView)view;

            if ((!ExprNodeUtility.DeepEquals(other.ExpressionX, _expressionX) ||
                 (!ExprNodeUtility.DeepEquals(other.ExpressionY, _expressionY))))
            {
                return(false);
            }

            return(true);
        }