Example #1
0
        public void Constructor_FaultTreeIllustrationPoint_CorrectValues()
        {
            // Setup
            var random   = new Random(31);
            var topLevel = new TopLevelFaultTreeIllustrationPoint(
                new WindDirection("N", 5.0),
                "closing situation",
                new IllustrationPointNode(new FaultTreeIllustrationPoint("Fault Tree A",
                                                                         3.14,
                                                                         new[]
            {
                new Stochast("Stochast A", 2.5, 5.5)
            },
                                                                         CombinationType.And)));

            topLevel.FaultTreeNodeRoot.SetChildren(new[]
            {
                new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")),
                new IllustrationPointNode(new TestSubMechanismIllustrationPoint("B"))
            });

            // Call
            var properties = new TopLevelFaultTreeIllustrationPointProperties(topLevel, random.NextBoolean());

            // Assert
            Assert.AreEqual(topLevel.WindDirection.Name, properties.WindDirection);

            TestHelper.AssertTypeConverter <TopLevelFaultTreeIllustrationPointProperties, NoValueRoundedDoubleConverter>(
                nameof(TopLevelFaultTreeIllustrationPointProperties.Reliability));
            Assert.AreEqual(3.14, properties.Reliability.Value);
            Assert.AreEqual(5, properties.Reliability.NumberOfDecimalPlaces);

            TestHelper.AssertTypeConverter <TopLevelFaultTreeIllustrationPointProperties, NoProbabilityValueDoubleConverter>(
                nameof(TopLevelFaultTreeIllustrationPointProperties.CalculatedProbability));
            Assert.AreEqual(StatisticsConverter.ReliabilityToProbability(3.14), properties.CalculatedProbability);

            Assert.AreEqual(topLevel.ClosingSituation, properties.ClosingSituation);

            TestHelper.AssertTypeConverter <TopLevelFaultTreeIllustrationPointProperties, KeyValueExpandableArrayConverter>(
                nameof(TopLevelFaultTreeIllustrationPointProperties.AlphaValues));
            Assert.IsNotNull(properties.AlphaValues);
            Assert.AreEqual(1, properties.AlphaValues.Length);
            Assert.AreEqual(5.5, properties.AlphaValues[0].Alpha);

            TestHelper.AssertTypeConverter <TopLevelFaultTreeIllustrationPointProperties, KeyValueExpandableArrayConverter>(
                nameof(TopLevelFaultTreeIllustrationPointProperties.Durations));
            Assert.IsNotNull(properties.Durations);
            Assert.AreEqual(1, properties.Durations.Length);
            Assert.AreEqual(2.5, properties.Durations[0].Duration);

            TestHelper.AssertTypeConverter <TopLevelFaultTreeIllustrationPointProperties, ExpandableArrayConverter>(
                nameof(TopLevelFaultTreeIllustrationPointProperties.IllustrationPoints));
            Assert.IsNotNull(properties.IllustrationPoints);
            Assert.AreEqual(2, properties.IllustrationPoints.Length);
        }
Example #2
0
        public void ToString_CorrectValue_ReturnsCorrectString()
        {
            // Setup
            var random = new Random(31);
            var topLevelFaultTreeIllustrationPoint = new TopLevelFaultTreeIllustrationPoint(
                new WindDirection("N", 5.0),
                "closing situation",
                new IllustrationPointNode(new TestFaultTreeIllustrationPoint()));

            var topLevelFaultTreeProperties = new TopLevelFaultTreeIllustrationPointProperties(topLevelFaultTreeIllustrationPoint, random.NextBoolean());

            // Call
            string toString = topLevelFaultTreeProperties.ToString();

            // Assert
            Assert.AreEqual("N", toString);
        }
Example #3
0
        public void Constructor_NoUniqueClosingSituations_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var topLevel = new TopLevelFaultTreeIllustrationPoint(
                new WindDirection("N", 5.0),
                "closing situation",
                new IllustrationPointNode(new TestFaultTreeIllustrationPoint()));

            // Call
            var properties = new TopLevelFaultTreeIllustrationPointProperties(topLevel, false);

            // Assert
            const string illustrationPointsCategoryName = "Illustratiepunten";

            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(7, dynamicProperties.Count);

            PropertyDescriptor probabilityProperty = dynamicProperties[probabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityProperty,
                                                                            illustrationPointsCategoryName,
                                                                            "Berekende kans [-]",
                                                                            "De berekende kans van voorkomen van het berekende resultaat.",
                                                                            true);

            PropertyDescriptor reliabilityProperty = dynamicProperties[reliabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(reliabilityProperty,
                                                                            illustrationPointsCategoryName,
                                                                            "Betrouwbaarheidsindex berekende kans [-]",
                                                                            "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.",
                                                                            true);

            PropertyDescriptor windDirectionProperty = dynamicProperties[windDirectionPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(windDirectionProperty,
                                                                            illustrationPointsCategoryName,
                                                                            "Windrichting",
                                                                            "De windrichting waarvoor dit illlustratiepunt is berekend.",
                                                                            true);

            PropertyDescriptor closingSituationProperty = dynamicProperties[closingSituationPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(closingSituationProperty,
                                                                            illustrationPointsCategoryName,
                                                                            "Keringsituatie",
                                                                            "De keringsituatie waarvoor dit illustratiepunt is berekend.",
                                                                            true);

            PropertyDescriptor alphasProperty = dynamicProperties[alphasPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(alphasProperty,
                                                                            illustrationPointsCategoryName,
                                                                            "Invloedscoëfficiënten [-]",
                                                                            "Berekende invloedscoëfficiënten voor alle beschouwde stochasten.",
                                                                            true);

            PropertyDescriptor durationsProperty = dynamicProperties[durationsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(durationsProperty,
                                                                            illustrationPointsCategoryName,
                                                                            "Tijdsduren [uur]",
                                                                            "Tijdsduren waarop de stochasten betrekking hebben.",
                                                                            true);

            PropertyDescriptor illustrationPointProperty = dynamicProperties[illustrationPointPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(illustrationPointProperty,
                                                                            illustrationPointsCategoryName,
                                                                            "Illustratiepunten",
                                                                            "De lijst van illustratiepunten voor de berekening.",
                                                                            true);
        }