Ejemplo n.º 1
0
        private IllustrationPointTreeNode BuildFaultTree(
            Tuple <int, WindDirection, int, string> windDirectionClosingSituation,
            int faultTreeId,
            CombinationType combinationType,
            IEnumerable <Tuple <int?, int, Type, CombinationType> > results)
        {
            var dataKey = new ThreeKeyIndex(windDirectionClosingSituation.Item1, windDirectionClosingSituation.Item3, faultTreeId);
            var faultTreeIllustrationPointStochasts = new List <Stochast>();

            if (!faultTreeBetaValues.ContainsKey(dataKey))
            {
                return(null);
            }

            if (faultTreeStochasts.ContainsKey(dataKey))
            {
                AddRange(faultTreeIllustrationPointStochasts, faultTreeStochasts[dataKey]);
            }

            var illustrationPoint = new FaultTreeIllustrationPoint(faultTrees[faultTreeId],
                                                                   faultTreeBetaValues[dataKey],
                                                                   faultTreeIllustrationPointStochasts,
                                                                   combinationType);

            var node = new IllustrationPointTreeNode(illustrationPoint);

            node.SetChildren(results.Where(r => r.Item1 == faultTreeId)
                             .Select(child => child.Item3 == typeof(FaultTreeIllustrationPoint)
                                                         ? BuildFaultTree(windDirectionClosingSituation, child.Item2, child.Item4, results)
                                                         : BuildSubMechanism(windDirectionClosingSituation, child.Item2)).ToArray());
            return(node);
        }
Ejemplo n.º 2
0
        public void SetChildren_ChildrenNull_ThrowsArgumentNullException()
        {
            // Setup
            var mocks = new MockRepository();
            var data  = mocks.Stub <IIllustrationPoint>();

            mocks.ReplayAll();

            var treeNode = new IllustrationPointTreeNode(data);

            // Call
            TestDelegate call = () => treeNode.SetChildren(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("children", exception.ParamName);

            mocks.VerifyAll();
        }
Ejemplo n.º 3
0
        public void SetChildren_ValidNrOfChildren_ReturnsExpectedProperties(int nrOfChildren)
        {
            // Setup
            var mocks = new MockRepository();
            var data  = mocks.Stub <IIllustrationPoint>();

            mocks.ReplayAll();

            var treeNode             = new IllustrationPointTreeNode(data);
            var childrenToBeAttached = new IllustrationPointTreeNode[nrOfChildren];

            // Call
            treeNode.SetChildren(childrenToBeAttached);

            // Assert
            IEnumerable <IllustrationPointTreeNode> addedChildren = treeNode.Children;

            Assert.AreSame(childrenToBeAttached, addedChildren);
            Assert.AreEqual(nrOfChildren, addedChildren.Count());
            mocks.VerifyAll();
        }
Ejemplo n.º 4
0
        public void SetChildren_InvalidNrOfChildren_ThrowsInvalidArgumentException(int nrOfChildren)
        {
            // Setup
            var mocks = new MockRepository();
            var data  = mocks.Stub <IIllustrationPoint>();

            mocks.ReplayAll();

            var treeNode             = new IllustrationPointTreeNode(data);
            var childrenToBeAttached = new IllustrationPointTreeNode[nrOfChildren];

            // Call
            TestDelegate call = () => treeNode.SetChildren(childrenToBeAttached);

            // Assert
            const string expectedMessage = "Een illustratiepunt node in de foutenboom moet 0 of 2 onderliggende nodes hebben.";
            var          exception       = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage);

            Assert.AreEqual("children", exception.ParamName);
            CollectionAssert.IsEmpty(treeNode.Children);
            mocks.VerifyAll();
        }