Exemple #1
0
        public void UpdatePointOutputChain_HasChild_ChildUpdatedToo()
        {
            var value = "test2";
            var eid   = 1;
            var point = A.Fake <IPoint>();

            A.CallTo(() => point.Eid).Returns(eid);
            A.CallTo(() => point.Value).Returns(value);

            var childValue = "test4";
            var eid2       = 2;
            var childPoint = A.Fake <IPoint>();

            A.CallTo(() => childPoint.Eid).Returns(eid2);
            A.CallTo(() => childPoint.Value).Returns(childValue);

            A.CallTo(() => _underlyingDirectedGraph.GetChildRelationOf(point))
            .Returns(new List <Tuple <IPoint, PointEquation> >
            {
                new Tuple <IPoint, PointEquation>(childPoint, null)
            });

            _pointUpdateStrategy.UpdatePointOutputChain(point);

            A.CallToSet(() => point.Output).To(value).MustHaveHappened();
            A.CallToSet(() => childPoint.Output).To(childValue).MustHaveHappened();
        }
Exemple #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);
            }
        }