Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs =================================================================== diff -u -r6ad24145747b52bf9b7d886e79767ddaa406e79b -r7c3de6e5d6d97e4078a3a2d1cd22abcf2ecfd8f1 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 6ad24145747b52bf9b7d886e79767ddaa406e79b) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 7c3de6e5d6d97e4078a3a2d1cd22abcf2ecfd8f1) @@ -21,11 +21,14 @@ using System; using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; using System.Linq; using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data; @@ -235,6 +238,253 @@ mockRepository.VerifyAll(); } + [Test] + [TestCase(double.MinValue)] + [TestCase(double.MaxValue)] + public void SetFailureProbabilityStructureWithErosion_InvalidValues_ThrowsArgumentException(double newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var failureMechanismStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var calculation = new StructuresCalculation(); + var inputContext = new SimpleInputContext(calculation.InputParameters, + calculation, + failureMechanismStub, + assessmentSectionStub); + var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()) + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue.ToString(CultureInfo.InvariantCulture); + + // Assert + var expectedMessage = "De waarde voor de faalkans is te groot of te klein."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + [TestCase("no double value")] + [TestCase("")] + public void SetFailureProbabilityStructureWithErosion_ValuesUnableToParse_ThrowsArgumentException(string newValue) + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var failureMechanismStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var calculation = new StructuresCalculation(); + var inputContext = new SimpleInputContext(calculation.InputParameters, + calculation, + failureMechanismStub, + assessmentSectionStub); + var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()) + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue; + + // Assert + var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + public void SetFailureProbabilityStructureWithErosion_NullValue_ThrowsArgumentNullException() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var failureMechanismStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var calculation = new StructuresCalculation(); + var inputContext = new SimpleInputContext(calculation.InputParameters, + calculation, + failureMechanismStub, + assessmentSectionStub); + var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties()) + { + Data = inputContext + }; + + // Call + TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = null; + + // Assert + var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + + mockRepository.VerifyAll(); + } + + [Test] + public void PropertyAttributes_ReturnExpectedValues() + { + // Setup + var assessmentSectionStub = mockRepository.Stub(); + var failureMechanismStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + const int structurePropertyIndex = 0; + const int structureLocationPropertyIndex = 1; + const int structureNormalOrientationPropertyIndex = 2; + const int flowWidthAtBottomProtectionPropertyIndex = 3; + const int widthFlowAperturesPropertyIndex = 4; + const int storageStructureAreaPropertyIndex = 5; + const int allowedLevelIncreaseStoragePropertyIndex = 6; + const int criticalOvertoppingDischargePropertyIndex = 7; + const int failureProbabilityStructureWithErosionPropertyIndex = 8; + const int foreshoreProfilePropertyIndex = 9; + const int useBreakWaterPropertyIndex = 10; + const int useForeshorePropertyIndex = 11; + const int modelFactorSuperCriticalFlowPropertyIndex = 12; + const int hydraulicBoundaryLocationPropertyIndex = 13; + const int stormDurationPropertyIndex = 14; + + var calculation = new StructuresCalculation(); + var inputContext = new SimpleInputContext(calculation.InputParameters, + calculation, + failureMechanismStub, + assessmentSectionStub); + // Call + var properties = new SimpleStructuresInputProperties(new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties + { + StructurePropertyIndex = structurePropertyIndex, + StructureLocationPropertyIndex = structureLocationPropertyIndex, + StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, + FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, + WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, + StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, + AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, + CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, + FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, + ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, + UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, + UseForeshorePropertyIndex = useForeshorePropertyIndex, + ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, + HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, + StormDurationPropertyIndex = stormDurationPropertyIndex + }) + { + Data = inputContext + }; + + // Assert + const string schematizationCategory = "Schematisatie"; + const string hydraulicDataCategory = "Hydraulische gegevens"; + const string modelSettingsCategory = "Modelinstellingen"; + + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(15, dynamicProperties.Count); + + PropertyDescriptor structureProperty = dynamicProperties[structurePropertyIndex]; + Assert.IsFalse(structureProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, structureProperty.Category); + Assert.AreEqual("Kunstwerk", structureProperty.DisplayName); + Assert.AreEqual("Het kunstwerk dat gebruikt wordt in de berekening.", structureProperty.Description); + + PropertyDescriptor structureLocationProperty = dynamicProperties[structureLocationPropertyIndex]; + Assert.IsTrue(structureLocationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, structureLocationProperty.Category); + Assert.AreEqual("Locatie (RD) [m]", structureLocationProperty.DisplayName); + Assert.AreEqual("De coördinaten van de locatie van het kunstwerk in het Rijksdriehoeksstelsel.", structureLocationProperty.Description); + + PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[structureNormalOrientationPropertyIndex]; + Assert.IsFalse(structureNormalOrientationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, structureNormalOrientationProperty.Category); + Assert.AreEqual("Oriëntatie [°]", structureNormalOrientationProperty.DisplayName); + Assert.AreEqual("Oriëntatie van de normaal van het kunstwerk ten opzichte van het noorden.", structureNormalOrientationProperty.Description); + + PropertyDescriptor flowWidthAtBottomProtectionProperty = dynamicProperties[flowWidthAtBottomProtectionPropertyIndex]; + Assert.IsInstanceOf(flowWidthAtBottomProtectionProperty.Converter); + Assert.AreEqual(schematizationCategory, flowWidthAtBottomProtectionProperty.Category); + Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", flowWidthAtBottomProtectionProperty.DisplayName); + Assert.AreEqual("Stroomvoerende breedte bodembescherming.", flowWidthAtBottomProtectionProperty.Description); + + PropertyDescriptor widthFlowAperturesProperty = dynamicProperties[widthFlowAperturesPropertyIndex]; + Assert.IsInstanceOf(widthFlowAperturesProperty.Converter); + Assert.AreEqual(schematizationCategory, widthFlowAperturesProperty.Category); + Assert.AreEqual("Breedte van doorstroomopening [m]", widthFlowAperturesProperty.DisplayName); + Assert.AreEqual("Breedte van de doorstroomopening.", widthFlowAperturesProperty.Description); + + PropertyDescriptor storageStructureAreaProperty = dynamicProperties[storageStructureAreaPropertyIndex]; + Assert.IsInstanceOf(storageStructureAreaProperty.Converter); + Assert.AreEqual(schematizationCategory, storageStructureAreaProperty.Category); + Assert.AreEqual("Kombergend oppervlak [m²]", storageStructureAreaProperty.DisplayName); + Assert.AreEqual("Kombergend oppervlak.", storageStructureAreaProperty.Description); + + PropertyDescriptor allowedLevelIncreaseStorageProperty = dynamicProperties[allowedLevelIncreaseStoragePropertyIndex]; + Assert.IsInstanceOf(allowedLevelIncreaseStorageProperty.Converter); + Assert.AreEqual(schematizationCategory, allowedLevelIncreaseStorageProperty.Category); + Assert.AreEqual("Toegestane peilverhoging komberging [m]", allowedLevelIncreaseStorageProperty.DisplayName); + Assert.AreEqual("Toegestane peilverhoging komberging.", allowedLevelIncreaseStorageProperty.Description); + + PropertyDescriptor criticalOvertoppingDischargeProperty = dynamicProperties[criticalOvertoppingDischargePropertyIndex]; + Assert.IsInstanceOf(criticalOvertoppingDischargeProperty.Converter); + Assert.AreEqual(schematizationCategory, criticalOvertoppingDischargeProperty.Category); + Assert.AreEqual("Kritiek instromend debiet [m³/s/m]", criticalOvertoppingDischargeProperty.DisplayName); + Assert.AreEqual("Kritiek instromend debiet directe invoer per strekkende meter.", criticalOvertoppingDischargeProperty.Description); + + PropertyDescriptor failureProbabilityStructureWithErosionProperty = dynamicProperties[failureProbabilityStructureWithErosionPropertyIndex]; + Assert.IsFalse(failureProbabilityStructureWithErosionProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, failureProbabilityStructureWithErosionProperty.Category); + Assert.AreEqual("Faalkans gegeven erosie bodem [1/jaar]", failureProbabilityStructureWithErosionProperty.DisplayName); + Assert.AreEqual("Faalkans kunstwerk gegeven erosie bodem.", failureProbabilityStructureWithErosionProperty.Description); + + PropertyDescriptor modelFactorSuperCriticalFlowProperty = dynamicProperties[modelFactorSuperCriticalFlowPropertyIndex]; + Assert.IsInstanceOf(modelFactorSuperCriticalFlowProperty.Converter); + Assert.AreEqual(modelSettingsCategory, modelFactorSuperCriticalFlowProperty.Category); + Assert.AreEqual("Modelfactor overloopdebiet volkomen overlaat [-]", modelFactorSuperCriticalFlowProperty.DisplayName); + Assert.AreEqual("Modelfactor voor het overloopdebiet over een volkomen overlaat.", modelFactorSuperCriticalFlowProperty.Description); + + PropertyDescriptor foreshoreProfileProperty = dynamicProperties[foreshoreProfilePropertyIndex]; + Assert.IsFalse(foreshoreProfileProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, foreshoreProfileProperty.Category); + Assert.AreEqual("Voorlandprofiel", foreshoreProfileProperty.DisplayName); + Assert.AreEqual("De schematisatie van het voorlandprofiel.", foreshoreProfileProperty.Description); + + PropertyDescriptor breakWaterProperty = dynamicProperties[useBreakWaterPropertyIndex]; + Assert.IsInstanceOf(breakWaterProperty.Converter); + Assert.IsTrue(breakWaterProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, breakWaterProperty.Category); + Assert.AreEqual("Dam", breakWaterProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de dam.", breakWaterProperty.Description); + + PropertyDescriptor foreshoreGeometryProperty = dynamicProperties[useForeshorePropertyIndex]; + Assert.IsInstanceOf(foreshoreGeometryProperty.Converter); + Assert.IsTrue(foreshoreGeometryProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, foreshoreGeometryProperty.Category); + Assert.AreEqual("Voorlandgeometrie", foreshoreGeometryProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", foreshoreGeometryProperty.Description); + + PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[hydraulicBoundaryLocationPropertyIndex]; + Assert.IsFalse(hydraulicBoundaryLocationProperty.IsReadOnly); + Assert.AreEqual(hydraulicDataCategory, hydraulicBoundaryLocationProperty.Category); + Assert.AreEqual("Locatie met hydraulische randvoorwaarden", hydraulicBoundaryLocationProperty.DisplayName); + Assert.AreEqual("De locatie met hydraulische randvoorwaarden.", hydraulicBoundaryLocationProperty.Description); + + PropertyDescriptor stormDurationProperty = dynamicProperties[stormDurationPropertyIndex]; + Assert.IsInstanceOf(stormDurationProperty.Converter); + Assert.AreEqual(hydraulicDataCategory, stormDurationProperty.Category); + Assert.AreEqual("Stormduur [uur]", stormDurationProperty.DisplayName); + Assert.AreEqual("Stormduur.", stormDurationProperty.Description); + + mockRepository.VerifyAll(); + } + private static HydraulicBoundaryLocation CreateHydraulicBoundaryLocation() { return new HydraulicBoundaryLocation(0, "", 0, 0); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r6ad24145747b52bf9b7d886e79767ddaa406e79b -r7c3de6e5d6d97e4078a3a2d1cd22abcf2ecfd8f1 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 6ad24145747b52bf9b7d886e79767ddaa406e79b) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 7c3de6e5d6d97e4078a3a2d1cd22abcf2ecfd8f1) @@ -21,14 +21,12 @@ using System; using System.ComponentModel; -using System.Globalization; using System.Linq; using Application.Ringtoets.Storage.TestUtil; using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; -using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; @@ -209,97 +207,6 @@ } [Test] - [TestCase(double.MinValue)] - [TestCase(double.MaxValue)] - public void SetFailureProbabilityStructureWithErosion_InvalidValues_ThrowsArgumentException(double newValue) - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var failureMechanism = new HeightStructuresFailureMechanism(); - var calculation = new StructuresCalculation(); - var inputContext = new HeightStructuresInputContext(calculation.InputParameters, - calculation, - failureMechanism, - assessmentSectionStub); - - var properties = new HeightStructuresInputContextProperties - { - Data = inputContext - }; - - // Call - TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue.ToString(CultureInfo.InvariantCulture); - - // Assert - var expectedMessage = "De waarde voor de faalkans is te groot of te klein."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - - mockRepository.VerifyAll(); - } - - [Test] - [TestCase("no double value")] - [TestCase("")] - public void SetFailureProbabilityStructureWithErosion_ValuesUnableToParse_ThrowsArgumentException(string newValue) - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var failureMechanism = new HeightStructuresFailureMechanism(); - var calculation = new StructuresCalculation(); - var inputContext = new HeightStructuresInputContext(calculation.InputParameters, - calculation, - failureMechanism, - assessmentSectionStub); - - var properties = new HeightStructuresInputContextProperties - { - Data = inputContext - }; - - // Call - TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = newValue; - - // Assert - var expectedMessage = "De waarde voor de faalkans kon niet geïnterpreteerd worden als een getal."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - - mockRepository.VerifyAll(); - } - - [Test] - public void SetFailureProbabilityStructureWithErosion_NullValue_ThrowsArgumentNullException() - { - // Setup - var assessmentSectionStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var failureMechanism = new HeightStructuresFailureMechanism(); - var calculation = new StructuresCalculation(); - var inputContext = new HeightStructuresInputContext(calculation.InputParameters, - calculation, - failureMechanism, - assessmentSectionStub); - - var properties = new HeightStructuresInputContextProperties - { - Data = inputContext - }; - - // Call - TestDelegate call = () => properties.FailureProbabilityStructureWithErosion = null; - - // Assert - var expectedMessage = "De waarde voor de faalkans moet ingevuld zijn."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - - mockRepository.VerifyAll(); - } - - [Test] public void PropertyAttributes_ReturnExpectedValues() { // Setup