예제 #1
0
        public void TestCopyView()
        {
            RegressionLinestView copied = (RegressionLinestView)_myView.CloneView();

            Assert.IsTrue(_myView.ExpressionX.Equals(copied.ExpressionX));
            Assert.IsTrue(_myView.ExpressionY.Equals(copied.ExpressionY));
        }
        private void TryParameter(Object[] @params, String fieldNameX, String fieldNameY)
        {
            _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(@params));
            _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null);
            RegressionLinestView view = (RegressionLinestView)_factory.MakeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext());

            Assert.AreEqual(fieldNameX, view.ExpressionX.ToExpressionStringMinPrecedenceSafe());
            Assert.AreEqual(fieldNameY, view.ExpressionY.ToExpressionStringMinPrecedenceSafe());
        }
        public void TestCanReuse()
        {
            _factory.SetViewParameters(_viewFactoryContext, 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 = RegressionLinestView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1);

            Assert.IsFalse(_factory.CanReuse(new RegressionLinestView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Price"), type, null)));
            Assert.IsFalse(_factory.CanReuse(new RegressionLinestView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), SupportExprNodeFactory.MakeIdentNodeMD("Price"), type, null)));
            Assert.IsTrue(_factory.CanReuse(new RegressionLinestView(null, SupportStatementContextFactory.MakeAgentInstanceContext(), SupportExprNodeFactory.MakeIdentNodeMD("Price"), SupportExprNodeFactory.MakeIdentNodeMD("Volume"), type, null)));
        }
예제 #4
0
        public void SetUp()
        {
            // Set up sum view and a test child view
            EventType type = RegressionLinestView.CreateEventType(SupportStatementContextFactory.MakeContext(), null, 1);

            RegressionLinestViewFactory viewFactory = new RegressionLinestViewFactory();

            _myView = new RegressionLinestView(viewFactory, 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       = RegressionLinestView.CreateEventType(statementContext, _additionalProps, _streamNumber);
        }
        public bool CanReuse(View view)
        {
            if (!(view is RegressionLinestView))
            {
                return(false);
            }

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

            RegressionLinestView myView = (RegressionLinestView)view;

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