Ejemplo n.º 1
0
        public void UpdatePointOutputChain_HasParent_OutputCalculatedViaStrategy()
        {
            var value = "test2";
            var eid   = 1;
            var point = A.Fake <IPoint>();

            A.CallTo(() => point.Eid).Returns(eid);
            var parentValue = "test4";
            var eid2        = 2;
            var parentPoint = A.Fake <IPoint>();

            var parentEquationValue = "1+1";
            var parentEquation      = new PointEquation(5, parentEquationValue);

            var correctOutput = "output";

            var parentRelations = new List <Tuple <IPoint, PointEquation> >
            {
                new Tuple <IPoint, PointEquation>(parentPoint, parentEquation)
            };

            A.CallTo(() => _underlyingDirectedGraph.GetParentRelationOf(point))
            .Returns(parentRelations);
            A.CallTo(() => _equationCalculateStrategy.CalculateEquation(point, parentRelations)).Returns(correctOutput);


            _pointUpdateStrategy.UpdatePointOutputChain(point);

            A.CallToSet(() => point.Output).To(correctOutput).MustHaveHappened();
        }
Ejemplo n.º 2
0
        private void UpdatePointOutputChainInternal(IPoint point, List <int> path)
        {
            if (path.Contains(point.Eid))
            {
                throw new CircularReferenceException();
            }
            path.Add(point.Eid);

            point.Output = point.Value;
            var parents = _underlyingDirectedGraph.GetParentRelationOf(point);

            if (parents.Any())
            {
                point.Output = _equationCalculateStrategy.CalculateEquation(point, parents);
            }

            foreach (var childRelation in _underlyingDirectedGraph.GetChildRelationOf(point))
            {
                UpdatePointOutputChainInternal(childRelation.Item1, path);
            }
        }