public void Constructor_DataIsNull_ThrowsArgumentNullException() { // Setup mockRepository.ReplayAll(); StructuresInputBaseProperties <TestStructure, SimpleStructureInput, StructuresCalculation <SimpleStructureInput>, IFailureMechanism> .ConstructionProperties constructionProperties = GetRandomConstructionProperties(); // Call TestDelegate call = () => new SimpleStructuresInputProperties(null, constructionProperties, handler); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("data", paramName); mockRepository.VerifyAll(); }
public void Constructor_ValidValues_ExpectedValues() { // Setup mockRepository.ReplayAll(); StructuresInputBaseProperties <TestStructure, SimpleStructureInput, StructuresCalculation <SimpleStructureInput>, IFailureMechanism> .ConstructionProperties constructionProperties = GetRandomConstructionProperties(); var calculation = new StructuresCalculation <SimpleStructureInput>(); var inputContext = new SimpleInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection); // Call var properties = new SimpleStructuresInputProperties( inputContext, constructionProperties, handler); // Assert Assert.IsInstanceOf <ObjectProperties <InputContextBase <SimpleStructureInput, StructuresCalculation <SimpleStructureInput>, IFailureMechanism> > >(properties); Assert.IsInstanceOf <IHasHydraulicBoundaryLocationProperty>(properties); Assert.IsInstanceOf <IHasStructureProperty <TestStructure> >(properties); Assert.IsInstanceOf <IHasForeshoreProfileProperty>(properties); Assert.AreSame(inputContext, properties.Data); SimpleStructureInput input = calculation.InputParameters; Assert.IsNull(properties.Structure); Assert.IsNull(properties.StructureLocation); Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation); Assert.AreSame(input.AllowedLevelIncreaseStorage, properties.AllowedLevelIncreaseStorage.Data); Assert.AreSame(input.StorageStructureArea, properties.StorageStructureArea.Data); Assert.AreSame(input.FlowWidthAtBottomProtection, properties.FlowWidthAtBottomProtection.Data); Assert.AreSame(input.WidthFlowApertures, properties.WidthFlowApertures.Data); Assert.AreSame(input.CriticalOvertoppingDischarge, properties.CriticalOvertoppingDischarge.Data); Assert.IsNull(properties.ForeshoreProfile); Assert.IsInstanceOf <UseBreakWaterProperties>(properties.UseBreakWater); Assert.IsInstanceOf <UseForeshoreProperties>(properties.UseForeshore); Assert.AreEqual(input.FailureProbabilityStructureWithErosion, properties.FailureProbabilityStructureWithErosion); Assert.IsNull(properties.SelectedHydraulicBoundaryLocation); Assert.AreSame(input.StormDuration, properties.StormDuration.Data); Assert.AreEqual(input.ShouldIllustrationPointsBeCalculated, properties.ShouldIllustrationPointsBeCalculated); const string generalCategory = "Algemeen"; const string schematizationIncomingFlowCategory = "Schematisering instromend debiet/volume"; const string schematizationGroundErosionCategory = "Schematisering bodembescherming"; const string schematizationStorageStructureCategory = "Schematisering komberging"; const string schematizationForeshoreCategory = "Voorland en (haven)dam"; const string outputSettingsCategory = "Uitvoer"; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(15, dynamicProperties.Count); PropertyDescriptor structureProperty = dynamicProperties[constructionProperties.StructurePropertyIndex]; Assert.IsFalse(structureProperty.IsReadOnly); Assert.AreEqual(generalCategory, structureProperty.Category); Assert.AreEqual("Kunstwerk", structureProperty.DisplayName); Assert.AreEqual("Het kunstwerk dat gebruikt wordt in de berekening.", structureProperty.Description); PropertyDescriptor structureLocationProperty = dynamicProperties[constructionProperties.StructureLocationPropertyIndex]; Assert.IsTrue(structureLocationProperty.IsReadOnly); Assert.AreEqual(generalCategory, 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 hydraulicBoundaryLocationProperty = dynamicProperties[constructionProperties.HydraulicBoundaryLocationPropertyIndex]; Assert.IsFalse(hydraulicBoundaryLocationProperty.IsReadOnly); Assert.AreEqual(generalCategory, hydraulicBoundaryLocationProperty.Category); Assert.AreEqual("Hydraulische belastingenlocatie", hydraulicBoundaryLocationProperty.DisplayName); Assert.AreEqual("De hydraulische belastingenlocatie.", hydraulicBoundaryLocationProperty.Description); PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[constructionProperties.StructureNormalOrientationPropertyIndex]; Assert.IsTrue(structureNormalOrientationProperty.IsReadOnly); Assert.AreEqual(schematizationIncomingFlowCategory, 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 widthFlowAperturesProperty = dynamicProperties[constructionProperties.WidthFlowAperturesPropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(widthFlowAperturesProperty.Converter); Assert.AreEqual(schematizationIncomingFlowCategory, widthFlowAperturesProperty.Category); Assert.AreEqual("Breedte van doorstroomopening [m]", widthFlowAperturesProperty.DisplayName); Assert.AreEqual("Breedte van de doorstroomopening.", widthFlowAperturesProperty.Description); PropertyDescriptor stormDurationProperty = dynamicProperties[constructionProperties.StormDurationPropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(stormDurationProperty.Converter); Assert.AreEqual(schematizationIncomingFlowCategory, stormDurationProperty.Category); Assert.AreEqual("Stormduur [uur]", stormDurationProperty.DisplayName); Assert.AreEqual("Stormduur.", stormDurationProperty.Description); PropertyDescriptor criticalOvertoppingDischargeProperty = dynamicProperties[constructionProperties.CriticalOvertoppingDischargePropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(criticalOvertoppingDischargeProperty.Converter); Assert.AreEqual(schematizationGroundErosionCategory, 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 flowWidthAtBottomProtectionProperty = dynamicProperties[constructionProperties.FlowWidthAtBottomProtectionPropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(flowWidthAtBottomProtectionProperty.Converter); Assert.AreEqual(schematizationGroundErosionCategory, flowWidthAtBottomProtectionProperty.Category); Assert.AreEqual("Stroomvoerende breedte bodembescherming [m]", flowWidthAtBottomProtectionProperty.DisplayName); Assert.AreEqual("Stroomvoerende breedte bodembescherming.", flowWidthAtBottomProtectionProperty.Description); PropertyDescriptor failureProbabilityStructureWithErosionProperty = dynamicProperties[constructionProperties.FailureProbabilityStructureWithErosionPropertyIndex]; Assert.IsFalse(failureProbabilityStructureWithErosionProperty.IsReadOnly); Assert.AreEqual(schematizationGroundErosionCategory, failureProbabilityStructureWithErosionProperty.Category); Assert.AreEqual("Faalkans gegeven erosie bodem [-]", failureProbabilityStructureWithErosionProperty.DisplayName); Assert.AreEqual("Faalkans kunstwerk gegeven erosie bodem.", failureProbabilityStructureWithErosionProperty.Description); PropertyDescriptor storageStructureAreaProperty = dynamicProperties[constructionProperties.StorageStructureAreaPropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(storageStructureAreaProperty.Converter); Assert.AreEqual(schematizationStorageStructureCategory, storageStructureAreaProperty.Category); Assert.AreEqual("Kombergend oppervlak [m²]", storageStructureAreaProperty.DisplayName); Assert.AreEqual("Kombergend oppervlak.", storageStructureAreaProperty.Description); PropertyDescriptor allowedLevelIncreaseStorageProperty = dynamicProperties[constructionProperties.AllowedLevelIncreaseStoragePropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(allowedLevelIncreaseStorageProperty.Converter); Assert.AreEqual(schematizationStorageStructureCategory, allowedLevelIncreaseStorageProperty.Category); Assert.AreEqual("Toegestane peilverhoging komberging [m]", allowedLevelIncreaseStorageProperty.DisplayName); Assert.AreEqual("Toegestane peilverhoging komberging.", allowedLevelIncreaseStorageProperty.Description); PropertyDescriptor foreshoreProfileProperty = dynamicProperties[constructionProperties.ForeshoreProfilePropertyIndex]; Assert.IsFalse(foreshoreProfileProperty.IsReadOnly); Assert.AreEqual(schematizationForeshoreCategory, foreshoreProfileProperty.Category); Assert.AreEqual("Voorlandprofiel", foreshoreProfileProperty.DisplayName); Assert.AreEqual("De schematisatie van het voorlandprofiel.", foreshoreProfileProperty.Description); PropertyDescriptor useBreakWaterProperty = dynamicProperties[constructionProperties.UseBreakWaterPropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(useBreakWaterProperty.Converter); Assert.IsTrue(useBreakWaterProperty.IsReadOnly); Assert.AreEqual(schematizationForeshoreCategory, useBreakWaterProperty.Category); Assert.AreEqual("Dam", useBreakWaterProperty.DisplayName); Assert.AreEqual("Eigenschappen van de dam.", useBreakWaterProperty.Description); PropertyDescriptor useForeshoreProperty = dynamicProperties[constructionProperties.UseForeshorePropertyIndex]; Assert.IsInstanceOf <ExpandableObjectConverter>(useForeshoreProperty.Converter); Assert.IsTrue(useForeshoreProperty.IsReadOnly); Assert.AreEqual(schematizationForeshoreCategory, useForeshoreProperty.Category); Assert.AreEqual("Voorlandgeometrie", useForeshoreProperty.DisplayName); Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", useForeshoreProperty.Description); int illustrationPointPropertyIndex = dynamicProperties.Count - 1; PropertyDescriptor shouldIllustrationPointsBeCalculatedProperty = dynamicProperties[illustrationPointPropertyIndex]; Assert.AreEqual(outputSettingsCategory, shouldIllustrationPointsBeCalculatedProperty.Category); Assert.AreEqual("Illustratiepunten inlezen", shouldIllustrationPointsBeCalculatedProperty.DisplayName); Assert.AreEqual("Neem de informatie over de illustratiepunten op in het berekeningsresultaat.", shouldIllustrationPointsBeCalculatedProperty.Description); mockRepository.VerifyAll(); }
public void Constructor_WithOrWithoutStructure_CorrectReadOnlyForStructureDependentProperties(bool hasStructure) { // Setup mockRepository.ReplayAll(); StructuresInputBaseProperties <TestStructure, SimpleStructureInput, StructuresCalculation <SimpleStructureInput>, IFailureMechanism> .ConstructionProperties constructionProperties = GetRandomConstructionProperties(); var calculation = new StructuresCalculation <SimpleStructureInput>(); var inputContext = new SimpleInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection); if (hasStructure) { calculation.InputParameters.Structure = new TestStructure(); } // Call var properties = new SimpleStructuresInputProperties( inputContext, constructionProperties, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); bool expectedReadOnly = !hasStructure; PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[constructionProperties.StructureNormalOrientationPropertyIndex]; Assert.AreEqual(expectedReadOnly, structureNormalOrientationProperty.IsReadOnly); AssertPropertiesInState(properties.FlowWidthAtBottomProtection, expectedReadOnly); AssertPropertiesInState(properties.WidthFlowApertures, expectedReadOnly); AssertPropertiesInState(properties.StorageStructureArea, expectedReadOnly); AssertPropertiesInState(properties.AllowedLevelIncreaseStorage, expectedReadOnly); AssertPropertiesInState(properties.CriticalOvertoppingDischarge, expectedReadOnly); }
public void Constructor_ChangeHandlerIsNull_ThrowsArgumentNullException() { // Setup StructuresInputBaseProperties <TestStructure, SimpleStructureInput, StructuresCalculation <SimpleStructureInput>, IFailureMechanism> .ConstructionProperties constructionProperties = GetRandomConstructionProperties(); var calculation = new StructuresCalculation <SimpleStructureInput>(); var inputContext = new SimpleInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection); // Call TestDelegate call = () => new SimpleStructuresInputProperties(inputContext, constructionProperties, null); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("propertyChangeHandler", paramName); }