コード例 #1
0
        /// <summary>
        /// Creates a new <see cref="GraphNode"/> based on the provided input.
        /// </summary>
        /// <param name="illustrationPoint">The illustration point.</param>
        /// <param name="childNodes">The child nodes of the illustration point.</param>
        /// <returns>The newly created <see cref="GraphNode"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is null.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="illustrationPoint"/>
        /// is not of type <see cref="FaultTreeIllustrationPoint"/> or <see cref="SubMechanismIllustrationPoint"/>.</exception>
        public static GraphNode CreateGraphNode(IllustrationPointBase illustrationPoint, IEnumerable <GraphNode> childNodes)
        {
            if (illustrationPoint == null)
            {
                throw new ArgumentNullException(nameof(illustrationPoint));
            }

            if (childNodes == null)
            {
                throw new ArgumentNullException(nameof(childNodes));
            }

            var subMechanismIllustrationPoint = illustrationPoint as SubMechanismIllustrationPoint;

            if (subMechanismIllustrationPoint != null)
            {
                return(CreateEndGraphNode(illustrationPoint.Name,
                                          CreateGraphNodeContent(illustrationPoint.Beta)));
            }

            var faultTreeIllustrationPoint = illustrationPoint as FaultTreeIllustrationPoint;

            if (faultTreeIllustrationPoint != null)
            {
                return(CreateFaultTreeGraphNode(faultTreeIllustrationPoint,
                                                childNodes));
            }

            throw new NotSupportedException($"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " +
                                            $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}");
        }
コード例 #2
0
        private static void AssertSubMechanismIllustrationPointEntity(IllustrationPointBase illustrationPoint,
                                                                      SubMechanismIllustrationPointEntity illustrationPointEntity)
        {
            Assert.IsNotNull(illustrationPoint);
            Assert.AreEqual(illustrationPoint.Beta, illustrationPointEntity.Beta, illustrationPoint.Beta.GetAccuracy());
            TestHelper.AssertAreEqualButNotSame(illustrationPoint.Name, illustrationPointEntity.Name);

            CollectionAssert.IsEmpty(illustrationPointEntity.IllustrationPointResultEntities);
            CollectionAssert.IsEmpty(illustrationPointEntity.SubMechanismIllustrationPointStochastEntities);
        }
コード例 #3
0
        /// <summary>
        /// Returns the stochasts of the <paramref name="illustrationPoint"/>.
        /// </summary>
        /// <param name="illustrationPoint">The illustration point to get the stochasts from.</param>
        /// <returns>The stochasts.</returns>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="illustrationPoint"/>
        /// is not of type <see cref="FaultTreeIllustrationPoint"/> or <see cref="SubMechanismIllustrationPoint"/>.</exception>
        private static IEnumerable <Stochast> GetStochasts(IllustrationPointBase illustrationPoint)
        {
            switch (illustrationPoint)
            {
            case FaultTreeIllustrationPoint faultTreeIllustrationPoint:
                return(faultTreeIllustrationPoint.Stochasts);

            case SubMechanismIllustrationPoint subMechanismIllustrationPoint:
                return(subMechanismIllustrationPoint.Stochasts);

            default:
                throw new NotSupportedException(
                          $"IllustrationPointNode of type {illustrationPoint.GetType().Name} is not supported. " +
                          $"Supported types: {nameof(FaultTreeIllustrationPoint)} and {nameof(SubMechanismIllustrationPoint)}");
            }
        }
コード例 #4
0
        /// <inheritdoc />
        /// <exception cref="NotSupportedException">Thrown when the top level fault tree illustration
        /// contains an illustration point that is not of type <see cref="FaultTreeIllustrationPoint"/>
        /// or <see cref="SubMechanismIllustrationPoint"/>.</exception>
        protected override IEnumerable <IllustrationPointControlItem> GetIllustrationPointControlItems()
        {
            GeneralResult <TopLevelFaultTreeIllustrationPoint> generalResult = GetGeneralResultFunc();

            if (generalResult == null)
            {
                return(Enumerable.Empty <IllustrationPointControlItem>());
            }

            return(generalResult.TopLevelIllustrationPoints.Select(topLevelFaultTreeIllustrationPoint =>
            {
                IllustrationPointBase illustrationPoint = topLevelFaultTreeIllustrationPoint.FaultTreeNodeRoot.Data;

                return new IllustrationPointControlItem(topLevelFaultTreeIllustrationPoint,
                                                        topLevelFaultTreeIllustrationPoint.WindDirection.Name,
                                                        topLevelFaultTreeIllustrationPoint.ClosingSituation,
                                                        GetStochasts(illustrationPoint),
                                                        illustrationPoint.Beta);
            }).ToArray());
        }
コード例 #5
0
 /// <summary>
 /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/>
 /// are clones.
 /// </summary>
 /// <param name="original">The original object.</param>
 /// <param name="clone">The cloned object.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and
 /// <paramref name="clone"/> are not clones.</exception>
 public static void AreClones(IllustrationPointBase original, IllustrationPointBase clone)
 {
     Assert.AreEqual(original.Name, clone.Name);
     Assert.AreEqual(original.Beta, clone.Beta);
 }