Esempio n. 1
0
        public void Constructor_ValidInputParameters_ExpectedValues()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculation      = new StructuresCalculation <HeightStructuresInput>();
            var failureMechanism = new HeightStructuresFailureMechanism();

            // Call
            var context = new HeightStructuresInputContext(calculation.InputParameters,
                                                           calculation,
                                                           failureMechanism,
                                                           assessmentSection);

            // Assert
            Assert.IsInstanceOf <InputContextBase <HeightStructuresInput, StructuresCalculation <HeightStructuresInput>, HeightStructuresFailureMechanism> >(context);
            Assert.AreSame(calculation.InputParameters, context.WrappedData);
            Assert.AreSame(calculation, context.Calculation);
            Assert.AreSame(failureMechanism, context.FailureMechanism);
            Assert.AreSame(assessmentSection, context.AssessmentSection);
            mocks.VerifyAll();
        }
        public void SetShouldIllustrationPointsBeCalculated_ValueChanged_UpdateDataAndNotifyObservers()
        {
            // Setup
            var  random     = new Random(21);
            bool newBoolean = random.NextBoolean();

            var observer = mockRepository.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());

            var handler = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var calculation      = new StructuresCalculation <HeightStructuresInput>();
            var failureMechanism = new HeightStructuresFailureMechanism();
            var inputContext     = new HeightStructuresInputContext(calculation.InputParameters,
                                                                    calculation,
                                                                    failureMechanism,
                                                                    assessmentSection);

            inputContext.Attach(observer);

            var properties = new HeightStructuresInputContextProperties(inputContext, handler);

            // Call
            properties.ShouldIllustrationPointsBeCalculated = newBoolean;

            // Assert
            Assert.AreEqual(newBoolean, calculation.InputParameters.ShouldIllustrationPointsBeCalculated);
            mockRepository.VerifyAll();
        }
        private void SetPropertyAndVerifyNotificationsAndOutput(Action <HeightStructuresInputContextProperties> setProperty)
        {
            // Setup
            var observable = mockRepository.StrictMock <IObservable>();

            observable.Expect(o => o.NotifyObservers());
            mockRepository.ReplayAll();

            var failureMechanism        = new HeightStructuresFailureMechanism();
            var calculation             = new StructuresCalculation <HeightStructuresInput>();
            HeightStructuresInput input = calculation.InputParameters;

            input.ForeshoreProfile = new TestForeshoreProfile();
            input.Structure        = new TestHeightStructure();

            var customHandler = new SetPropertyValueAfterConfirmationParameterTester(new[]
            {
                observable
            });

            var inputContext = new HeightStructuresInputContext(input,
                                                                calculation,
                                                                failureMechanism,
                                                                assessmentSection);
            var properties = new HeightStructuresInputContextProperties(inputContext, customHandler);

            // Call
            setProperty(properties);

            // Assert
            Assert.IsFalse(calculation.HasOutput);

            mockRepository.VerifyAll();
        }
        public void GetAvailableStructures_SetInputContextInstanceWithStructures_ReturnStructures()
        {
            // Setup
            var handler = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var failureMechanism = new HeightStructuresFailureMechanism();

            failureMechanism.HeightStructures.AddRange(new[]
            {
                new TestHeightStructure()
            }, "some folder");
            var calculation  = new StructuresCalculation <HeightStructuresInput>();
            var inputContext = new HeightStructuresInputContext(calculation.InputParameters,
                                                                calculation,
                                                                failureMechanism,
                                                                assessmentSection);
            var properties = new HeightStructuresInputContextProperties(inputContext, handler);

            // Call
            IEnumerable <HeightStructure> availableStructures = properties.GetAvailableStructures();

            // Assert
            Assert.AreSame(failureMechanism.HeightStructures, availableStructures);
            mockRepository.VerifyAll();
        }
        public void Constructor_WithOrWithoutStructure_CorrectReadOnlyForStructureDependentProperties(bool hasStructure)
        {
            // Setup
            var handler = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var failureMechanism = new HeightStructuresFailureMechanism();
            var calculation      = new StructuresCalculation <HeightStructuresInput>();
            var inputContext     = new HeightStructuresInputContext(calculation.InputParameters,
                                                                    calculation,
                                                                    failureMechanism,
                                                                    assessmentSection);

            if (hasStructure)
            {
                calculation.InputParameters.Structure = new TestHeightStructure();
            }

            // Call
            var properties = new HeightStructuresInputContextProperties(inputContext, handler);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
            bool expectedReadOnly = !hasStructure;

            PropertyDescriptor failureProbabilityStructureWithErosionProperty = dynamicProperties[failureProbabilityStructureWithErosionPropertyIndex];

            Assert.AreEqual(expectedReadOnly, failureProbabilityStructureWithErosionProperty.IsReadOnly);

            DistributionPropertiesTestHelper.AssertPropertiesAreReadOnly(properties.LevelCrestStructure, expectedReadOnly, expectedReadOnly);

            mockRepository.VerifyAll();
        }
Esempio n. 6
0
        public void Text_Always_ReturnsTextFromResource()
        {
            // Setup
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            mocksRepository.ReplayAll();

            var heightStructuresCalculation  = new StructuresCalculation <HeightStructuresInput>();
            var heightStructuresInputContext = new HeightStructuresInputContext(
                heightStructuresCalculation.InputParameters,
                heightStructuresCalculation,
                new HeightStructuresFailureMechanism(),
                assessmentSection);

            // Call
            string text = info.Text(heightStructuresInputContext);

            // Assert
            Assert.AreEqual("Invoer", text);
        }
Esempio n. 7
0
        public void Image_Always_ReturnsSetImage()
        {
            // Setup
            var assessmentSection = mocksRepository.Stub <IAssessmentSection>();

            mocksRepository.ReplayAll();

            var heightStructuresCalculation  = new StructuresCalculation <HeightStructuresInput>();
            var heightStructuresInputContext = new HeightStructuresInputContext(
                heightStructuresCalculation.InputParameters,
                heightStructuresCalculation,
                new HeightStructuresFailureMechanism(),
                assessmentSection);

            // Call
            Image image = info.Image(heightStructuresInputContext);

            // Assert
            TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.GenericInputOutputIcon, image);
        }
 /// <summary>
 /// Creates a new instance of the <see cref="HeightStructuresInputContextProperties"/> class.
 /// </summary>
 /// <param name="data">The instance to show the properties of.</param>
 /// <param name="propertyChangeHandler">The handler responsible for handling effects of a property change.</param>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
 public HeightStructuresInputContextProperties(HeightStructuresInputContext data, IObservablePropertyChangeHandler propertyChangeHandler)
     : base(data, new 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,
     HydraulicBoundaryLocationPropertyIndex              = hydraulicBoundaryLocationPropertyIndex,
     StormDurationPropertyIndex                          = stormDurationPropertyIndex
 }, propertyChangeHandler)
 {
 }
        public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismContextAsData()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            mocks.ReplayAll();

            var calculation      = new TestHeightStructuresCalculationScenario();
            var failureMechanism = new HeightStructuresFailureMechanism();
            var context          = new HeightStructuresInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection);

            // Call
            IObjectProperties objectProperties = info.CreateInstance(context);

            // Assert
            Assert.IsInstanceOf <HeightStructuresInputContextProperties>(objectProperties);
            Assert.AreSame(context, objectProperties.Data);

            mocks.VerifyAll();
        }
        public void Constructor_WithoutHandler_ThrowsArgumentNullException()
        {
            // Setup
            mockRepository.ReplayAll();

            var failureMechanism = new HeightStructuresFailureMechanism();
            var calculation      = new StructuresCalculation <HeightStructuresInput>();

            var inputContext = new HeightStructuresInputContext(calculation.InputParameters,
                                                                calculation,
                                                                failureMechanism,
                                                                assessmentSection);

            // Call
            TestDelegate test = () => new HeightStructuresInputContextProperties(inputContext, null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(test).ParamName;

            Assert.AreEqual("propertyChangeHandler", paramName);
        }
        public void Constructor_WithData_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var handler = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var failureMechanism = new HeightStructuresFailureMechanism();
            var calculation      = new StructuresCalculation <HeightStructuresInput>();
            var inputContext     = new HeightStructuresInputContext(calculation.InputParameters,
                                                                    calculation,
                                                                    failureMechanism,
                                                                    assessmentSection);

            // Call
            var properties = new HeightStructuresInputContextProperties(inputContext, handler);

            // Assert
            const string generalCategory       = "\t\t\t\t\t\tAlgemeen";
            const string modelSettingsCategory = "\t\t\t\t\tModelinstellingen";
            const string schematizationIncomingFlowCategory     = "\t\t\t\tSchematisering instromend debiet/volume";
            const string schematizationGroundErosionCategory    = "\t\t\tSchematisering bodembescherming";
            const string schematizationStorageStructureCategory = "\t\tSchematisering komberging";
            const string foreshoreCategory      = "\tVoorland en (haven)dam";
            const string outputSettingsCategory = "Uitvoer";

            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(17, dynamicProperties.Count);

            PropertyDescriptor structureProperty = dynamicProperties[structurePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(structureProperty,
                                                                            generalCategory,
                                                                            "Kunstwerk",
                                                                            "Het kunstwerk dat gebruikt wordt in de berekening.");

            PropertyDescriptor structureLocationProperty = dynamicProperties[structureLocationPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(structureLocationProperty,
                                                                            generalCategory,
                                                                            "Locatie (RD) [m]",
                                                                            "De coördinaten van de locatie van het kunstwerk in het Rijksdriehoeksstelsel.",
                                                                            true);

            PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[hydraulicBoundaryLocationPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(hydraulicBoundaryLocationProperty,
                                                                            generalCategory,
                                                                            "Hydraulische belastingenlocatie",
                                                                            "De hydraulische belastingenlocatie.");

            PropertyDescriptor modelFactorSuperCriticalFlowProperty = dynamicProperties[modelFactorSuperCriticalFlowPropertyIndex];

            Assert.IsInstanceOf <ExpandableObjectConverter>(modelFactorSuperCriticalFlowProperty.Converter);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorSuperCriticalFlowProperty,
                                                                            modelSettingsCategory,
                                                                            "Modelfactor overloopdebiet volkomen overlaat [-]",
                                                                            "Modelfactor voor het overloopdebiet over een volkomen overlaat.",
                                                                            true);

            PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[structureNormalOrientationPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(structureNormalOrientationProperty,
                                                                            schematizationIncomingFlowCategory,
                                                                            "Oriëntatie [°]",
                                                                            "Oriëntatie van de normaal van het kunstwerk ten opzichte van het noorden.",
                                                                            true);

            PropertyDescriptor levelCrestStructureProperty = dynamicProperties[levelCrestStructurePropertyIndex];

            Assert.IsInstanceOf <ExpandableObjectConverter>(levelCrestStructureProperty.Converter);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(levelCrestStructureProperty,
                                                                            schematizationIncomingFlowCategory,
                                                                            "Kerende hoogte [m+NAP]",
                                                                            "Kerende hoogte van het kunstwerk.",
                                                                            true);

            PropertyDescriptor widthFlowAperturesProperty = dynamicProperties[widthFlowAperturesPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(widthFlowAperturesProperty,
                                                                            schematizationIncomingFlowCategory,
                                                                            "Breedte van doorstroomopening [m]",
                                                                            "Breedte van de doorstroomopening.",
                                                                            true);

            PropertyDescriptor stormDurationProperty = dynamicProperties[stormDurationPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(stormDurationProperty,
                                                                            schematizationIncomingFlowCategory,
                                                                            "Stormduur [uur]",
                                                                            "Stormduur.",
                                                                            true);

            PropertyDescriptor criticalOvertoppingDischargeProperty = dynamicProperties[criticalOvertoppingDischargePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(criticalOvertoppingDischargeProperty,
                                                                            schematizationGroundErosionCategory,
                                                                            "Kritiek instromend debiet [m³/s/m]",
                                                                            "Kritiek instromend debiet directe invoer per strekkende meter.",
                                                                            true);

            PropertyDescriptor flowWidthAtBottomProtectionProperty = dynamicProperties[flowWidthAtBottomProtectionPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(flowWidthAtBottomProtectionProperty,
                                                                            schematizationGroundErosionCategory,
                                                                            "Stroomvoerende breedte bodembescherming [m]",
                                                                            "Stroomvoerende breedte bodembescherming.",
                                                                            true);

            PropertyDescriptor failureProbabilityStructureWithErosionProperty = dynamicProperties[failureProbabilityStructureWithErosionPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureProbabilityStructureWithErosionProperty,
                                                                            schematizationGroundErosionCategory,
                                                                            "Faalkans gegeven erosie bodem [-]",
                                                                            "Faalkans kunstwerk gegeven erosie bodem.",
                                                                            true);

            PropertyDescriptor storageStructureAreaProperty = dynamicProperties[storageStructureAreaPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(storageStructureAreaProperty,
                                                                            schematizationStorageStructureCategory,
                                                                            "Kombergend oppervlak [m²]",
                                                                            "Kombergend oppervlak.",
                                                                            true);

            PropertyDescriptor allowedLevelIncreaseStorageProperty = dynamicProperties[allowedLevelIncreaseStoragePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(allowedLevelIncreaseStorageProperty,
                                                                            schematizationStorageStructureCategory,
                                                                            "Toegestane peilverhoging komberging [m]",
                                                                            "Toegestane peilverhoging komberging.",
                                                                            true);

            PropertyDescriptor foreshoreProfileProperty = dynamicProperties[foreshoreProfilePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(foreshoreProfileProperty,
                                                                            foreshoreCategory,
                                                                            "Voorlandprofiel",
                                                                            "De schematisatie van het voorlandprofiel.");

            PropertyDescriptor useBreakWaterProperty = dynamicProperties[useBreakWaterPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(useBreakWaterProperty,
                                                                            foreshoreCategory,
                                                                            "Dam",
                                                                            "Eigenschappen van de dam.",
                                                                            true);

            PropertyDescriptor useForeshoreProperty = dynamicProperties[useForeshorePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(useForeshoreProperty,
                                                                            foreshoreCategory,
                                                                            "Voorlandgeometrie",
                                                                            "Eigenschappen van de voorlandgeometrie.",
                                                                            true);

            PropertyDescriptor shouldIllustrationPointsBeCalculatedProperty = dynamicProperties[calculateIllustrationPointsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(shouldIllustrationPointsBeCalculatedProperty,
                                                                            outputSettingsCategory,
                                                                            "Illustratiepunten inlezen",
                                                                            "Neem de informatie over de illustratiepunten op in het berekeningsresultaat.");

            mockRepository.VerifyAll();
        }
        public void Constructor_WithData_ExpectedValues()
        {
            // Setup
            var handler = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var failureMechanism = new HeightStructuresFailureMechanism();
            var calculation      = new StructuresCalculation <HeightStructuresInput>
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
                    Structure        = new TestHeightStructure(),
                    ForeshoreProfile = new TestForeshoreProfile()
                }
            };

            var inputContext = new HeightStructuresInputContext(calculation.InputParameters,
                                                                calculation,
                                                                failureMechanism,
                                                                assessmentSection);

            // Call
            var properties = new HeightStructuresInputContextProperties(inputContext, handler);

            // Assert
            Assert.IsInstanceOf <StructuresInputBaseProperties <HeightStructure, HeightStructuresInput, StructuresCalculation <HeightStructuresInput>,
                                                                HeightStructuresFailureMechanism> >(properties);
            Assert.AreSame(inputContext, properties.Data);

            HeightStructuresInput input = calculation.InputParameters;

            Assert.AreSame(input.Structure, properties.Structure);
            Assert.AreEqual(input.Structure.Location.X, properties.StructureLocation.X, 1);
            Assert.AreEqual(input.Structure.Location.Y, properties.StructureLocation.Y, 1);
            Assert.AreSame(input.HydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation);

            Assert.AreSame(input.ModelFactorSuperCriticalFlow, properties.ModelFactorSuperCriticalFlow.Data);

            Assert.AreEqual(input.StructureNormalOrientation, properties.StructureNormalOrientation);
            Assert.AreSame(input.LevelCrestStructure, properties.LevelCrestStructure.Data);
            Assert.AreSame(input.WidthFlowApertures, properties.WidthFlowApertures.Data);
            Assert.AreSame(input.StormDuration, properties.StormDuration.Data);

            Assert.AreSame(input.CriticalOvertoppingDischarge, properties.CriticalOvertoppingDischarge.Data);
            Assert.AreSame(input.FlowWidthAtBottomProtection, properties.FlowWidthAtBottomProtection.Data);
            Assert.AreEqual(input.FailureProbabilityStructureWithErosion, properties.FailureProbabilityStructureWithErosion);

            Assert.AreSame(input.StorageStructureArea, properties.StorageStructureArea.Data);
            Assert.AreSame(input.AllowedLevelIncreaseStorage, properties.AllowedLevelIncreaseStorage.Data);

            Assert.AreSame(input.ForeshoreProfile, properties.ForeshoreProfile);
            Assert.IsInstanceOf <UseBreakWaterProperties>(properties.UseBreakWater);
            Assert.IsInstanceOf <UseForeshoreProperties>(properties.UseForeshore);

            Assert.AreEqual(input.ShouldIllustrationPointsBeCalculated, properties.ShouldIllustrationPointsBeCalculated);

            TestHelper.AssertTypeConverter <HeightStructuresInputContextProperties, NoProbabilityValueDoubleConverter>(
                nameof(HeightStructuresInputContextProperties.FailureProbabilityStructureWithErosion));

            DistributionPropertiesTestHelper.AssertPropertiesAreReadOnly(properties.ModelFactorSuperCriticalFlow, false, true);

            mockRepository.VerifyAll();
        }