Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/IllustrationPointPropertiesTest.cs =================================================================== diff -u -r9c8a4be86a9b3659738256e8f1c0542339d7b16a -ra49798da6ac2176d2e8b28ec6fec8a2494d8ee91 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/IllustrationPointPropertiesTest.cs (.../IllustrationPointPropertiesTest.cs) (revision 9c8a4be86a9b3659738256e8f1c0542339d7b16a) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/IllustrationPointPropertiesTest.cs (.../IllustrationPointPropertiesTest.cs) (revision a49798da6ac2176d2e8b28ec6fec8a2494d8ee91) @@ -43,37 +43,25 @@ private const int reliabilityPropertyIndex = 1; private const int windDirectionPropertyIndex = 2; private const int closingScenarioPropertyIndex = 3; - private const int illustrationPointPropertyIndex = 4; [Test] public void Constructor_IllustrationPointNull_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new IllustrationPointProperties(null, new IllustrationPointNode[0], - "Point name A", "Closing Situation"); + TestDelegate test = () => new IllustrationPointProperties(null, + "Point name A", + "Closing Situation"); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("illustrationPoint", paramName); } [Test] - public void Constructor_ChildNodesNull_ThrowsArgumentNullException() - { - // Call - TestDelegate test = () => new IllustrationPointProperties(new TestIllustrationPoint(), null, "Point name A", "Closing Situation"); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("childNodes", paramName); - } - - [Test] public void Constructor_WindDirectionNull_ThrowsArgumentNullException() { // Call TestDelegate test = () => new IllustrationPointProperties(new TestIllustrationPoint(), - new IllustrationPointNode[0], null, "Closing Situation"); @@ -87,7 +75,6 @@ { // Call TestDelegate test = () => new IllustrationPointProperties(new TestIllustrationPoint(), - new IllustrationPointNode[0], "SE", null); @@ -108,61 +95,35 @@ random.NextDouble(), Enumerable.Empty(), Enumerable.Empty()); - var childNodes = new[] - { - new IllustrationPointNode(new FaultTreeIllustrationPoint("Fault Tree A", - random.NextDouble(), - Enumerable.Empty(), - CombinationType.And)), - new IllustrationPointNode(new SubMechanismIllustrationPoint("Sub Mechanism B", - 4.2, - Enumerable.Empty(), - Enumerable.Empty())) - }; // Call - var properties = new IllustrationPointProperties(illustrationPoint, childNodes, windDirection, closingSituation); + var properties = new IllustrationPointProperties(illustrationPoint, windDirection, closingSituation); // Assert - PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - - PropertyDescriptor illustrationPointProperty = dynamicProperties[illustrationPointPropertyIndex]; - Assert.NotNull(illustrationPointProperty.Attributes[typeof(KeyValueElementAttribute)]); - Assert.AreEqual(windDirection, properties.WindDirection); TestHelper.AssertTypeConverter( nameof(IllustrationPointProperties.Reliability)); Assert.AreEqual(illustrationPoint.Beta, properties.Reliability, properties.Reliability.GetAccuracy()); - Assert.AreEqual(5, properties.Reliability.NumberOfDecimalPlaces); TestHelper.AssertTypeConverter( nameof(IllustrationPointProperties.CalculatedProbability)); Assert.AreEqual(StatisticsConverter.ReliabilityToProbability(illustrationPoint.Beta), properties.CalculatedProbability); Assert.AreEqual(closingSituation, properties.ClosingSituation); - - TestHelper.AssertTypeConverter( - nameof(IllustrationPointProperties.IllustrationPoints)); - Assert.AreEqual(childNodes.Length, properties.IllustrationPoints.Length); } [Test] - public void Constructor_WithChildIllustrationPointNodes_PropertiesHaveExpectedAttributesValues() + public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup - var illustrationPoint = new TestFaultTreeIllustrationPoint(); - var children = new[] - { - new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")), - new IllustrationPointNode(new TestFaultTreeIllustrationPoint("B")) - }; + var illustrationPointNode = new IllustrationPointNode(new TestSubMechanismIllustrationPoint()); // Call - var properties = new IllustrationPointProperties(illustrationPoint, children, "N", "Closing Situation"); + var properties = new IllustrationPointProperties(illustrationPointNode.Data, "N", "Closing Situation"); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(5, dynamicProperties.Count); + Assert.AreEqual(4, dynamicProperties.Count); PropertyDescriptor probabilityProperty = dynamicProperties[probabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityProperty, @@ -191,29 +152,20 @@ "Sluitscenario", "Het sluitscenario waarvoor dit illustratiepunt is berekend.", true); - - PropertyDescriptor illustrationPointProperty = dynamicProperties[illustrationPointPropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(illustrationPointProperty, - illustrationPointCategoryName, - "Illustratiepunten", - "De lijst van illustratiepunten voor de berekening.", - true); } [Test] - public void Constructor_WithoutChildIllustrationPointNodes_PropertiesHaveExpectedAttributesValues() + public void Constructor_NoClosingSituation_PropertiesHaveExpectedAttributesValues() { // Setup - var illustrationPointNode = new IllustrationPointNode(new TestSubMechanismIllustrationPoint()); + var illustrationPoint = new TestFaultTreeIllustrationPoint(); // Call - var properties = new IllustrationPointProperties(illustrationPointNode.Data, new IllustrationPointNode[0], "N", "Closing " + - "Situation" + - ""); + var properties = new IllustrationPointProperties(illustrationPoint, "N", string.Empty); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(4, dynamicProperties.Count); + Assert.AreEqual(3, dynamicProperties.Count); PropertyDescriptor probabilityProperty = dynamicProperties[probabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityProperty, @@ -235,78 +187,74 @@ "Windrichting", "De windrichting waarvoor dit illlustratiepunt is berekend.", true); + } - PropertyDescriptor closingScenarioProperty = dynamicProperties[closingScenarioPropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(closingScenarioProperty, - illustrationPointCategoryName, - "Sluitscenario", - "Het sluitscenario waarvoor dit illustratiepunt is berekend.", - true); + [Test] + public void ToString_Always_ReturnIllustrationPointName() + { + // Setup + const string name = "ImportantName"; + var illustrationPoint = new TestFaultTreeIllustrationPoint(name); + var properties = new IllustrationPointProperties(illustrationPoint, + "NotImportant", + "Closing Situation"); + + // Call + string toString = properties.ToString(); + + // Assert + Assert.AreEqual(name, toString); } [Test] - public void Constructor_NoClosingSituation_PropertiesHaveExpectedAttributesValues() + public void IsDynamicVisible_WithClosingSituation_ReturnsTrue() { // Setup var illustrationPoint = new TestFaultTreeIllustrationPoint(); - var childNodes = new[] - { - new IllustrationPointNode(new TestFaultTreeIllustrationPoint("A")), - new IllustrationPointNode(new TestFaultTreeIllustrationPoint("B")) - }; + var properties = new IllustrationPointProperties(illustrationPoint, + "NotImportant", + "Closing Situation"); // Call - var properties = new IllustrationPointProperties(illustrationPoint, childNodes, "N", string.Empty); + bool isVisible = properties.IsDynamicVisible(nameof(IllustrationPointProperties.ClosingSituation)); // Assert - PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(4, dynamicProperties.Count); + Assert.IsTrue(isVisible); + } - PropertyDescriptor probabilityProperty = dynamicProperties[probabilityPropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityProperty, - illustrationPointCategoryName, - "Berekende kans [1/jaar]", - "De berekende kans van voorkomen van het berekende resultaat.", - true); + [Test] + public void IsDynamicVisible_WithEmptyClosingSituation_ReturnsFalse() + { + // Setup + var illustrationPoint = new TestFaultTreeIllustrationPoint(); + var properties = new IllustrationPointProperties(illustrationPoint, + "NotImportant", + string.Empty); - PropertyDescriptor reliabilityProperty = dynamicProperties[reliabilityPropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(reliabilityProperty, - illustrationPointCategoryName, - "Betrouwbaarheidsindex berekende kans [-]", - "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", - true); + // Call + bool isVisible = properties.IsDynamicVisible(nameof(IllustrationPointProperties.ClosingSituation)); - PropertyDescriptor windDirectionProperty = dynamicProperties[windDirectionPropertyIndex]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(windDirectionProperty, - illustrationPointCategoryName, - "Windrichting", - "De windrichting waarvoor dit illlustratiepunt is berekend.", - true); - - PropertyDescriptor illustrationPointProperty = dynamicProperties[illustrationPointPropertyIndex - 1]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(illustrationPointProperty, - illustrationPointCategoryName, - "Illustratiepunten", - "De lijst van illustratiepunten voor de berekening.", - true); + // Assert + Assert.IsFalse(isVisible); } [Test] - public void ToString_Always_ReturnIllustrationPointName() + [TestCase(nameof(IllustrationPointProperties.WindDirection))] + [TestCase(nameof(IllustrationPointProperties.CalculatedProbability))] + [TestCase(nameof(IllustrationPointProperties.Reliability))] + public void IsDynamicVisible_WithOtherProperties_ReturnsFalse(string property) { // Setup - const string name = "ImportantName"; - var illustrationPoint = new TestFaultTreeIllustrationPoint(name); + var illustrationPoint = new TestFaultTreeIllustrationPoint(); var properties = new IllustrationPointProperties(illustrationPoint, - new IllustrationPointNode[0], "NotImportant", - "Closing Situation"); + string.Empty); // Call - string toString = properties.ToString(); + bool isVisible = properties.IsDynamicVisible(property); // Assert - Assert.AreEqual(name, toString); + Assert.IsFalse(isVisible); } } } \ No newline at end of file