public void Constructor_ExpectedProperties()
        {
            // Setup
            var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation());

            // Call
            var properties = new TestHydraulicBoundaryLocationCalculationBaseProperties(hydraulicBoundaryLocationCalculation);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <HydraulicBoundaryLocationCalculation> >(properties);
            Assert.IsInstanceOf <ExpandableObjectConverter>(TypeDescriptor.GetConverter(properties, true));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, NoValueRoundedDoubleConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.Result));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, NoProbabilityValueDoubleConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.TargetProbability));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, NoValueRoundedDoubleConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.TargetReliability));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, NoProbabilityValueDoubleConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.CalculatedProbability));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, NoValueRoundedDoubleConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.CalculatedReliability));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, EnumTypeConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.Convergence));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, KeyValueExpandableArrayConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.AlphaValues));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, KeyValueExpandableArrayConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.Durations));
            TestHelper.AssertTypeConverter <HydraulicBoundaryLocationCalculationProperties, ExpandableArrayConverter>(
                nameof(HydraulicBoundaryLocationCalculationProperties.IllustrationPoints));
        }
        public void ShouldIllustrationPointsBeCalculated_SetNewValue_NotifyObservers()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

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

            var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = false
                }
            };

            hydraulicBoundaryLocationCalculation.Attach(observer);

            var properties = new TestHydraulicBoundaryLocationCalculationBaseProperties(hydraulicBoundaryLocationCalculation);

            // Call
            properties.ShouldIllustrationPointsBeCalculated = true;

            // Assert
            Assert.IsTrue(hydraulicBoundaryLocationCalculation.InputParameters.ShouldIllustrationPointsBeCalculated);
            mocks.VerifyAll();
        }
        public void Constructor_WithGeneralIllustrationPointsResult_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
            {
                Output = new TestHydraulicBoundaryLocationCalculationOutput(new TestGeneralResultSubMechanismIllustrationPoint())
            };

            // Call
            var properties = new TestHydraulicBoundaryLocationCalculationBaseProperties(hydraulicBoundaryLocationCalculation);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(11, dynamicProperties.Count);

            const string resultCategory             = "Resultaat";
            const string illustrationPointsCategory = "Illustratiepunten";

            PropertyDescriptor resultProperty = dynamicProperties[resultPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(resultProperty,
                                                                            resultCategory,
                                                                            nameof(properties.Result),
                                                                            "",
                                                                            true);

            PropertyDescriptor targetProbabilityProperty = dynamicProperties[targetProbabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetProbabilityProperty,
                                                                            resultCategory,
                                                                            "Doelkans [1/jaar]",
                                                                            "De ingevoerde kans waarvoor het resultaat moet worden berekend.",
                                                                            true);

            PropertyDescriptor targetReliabilityProperty = dynamicProperties[targetReliabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetReliabilityProperty,
                                                                            resultCategory,
                                                                            "Betrouwbaarheidsindex doelkans [-]",
                                                                            "Betrouwbaarheidsindex van de ingevoerde kans waarvoor het resultaat moet worden berekend.",
                                                                            true);

            PropertyDescriptor calculatedProbabilityProperty = dynamicProperties[calculatedProbabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedProbabilityProperty,
                                                                            resultCategory,
                                                                            "Berekende kans [1/jaar]",
                                                                            "De berekende kans van voorkomen van het berekende resultaat.",
                                                                            true);

            PropertyDescriptor calculatedReliabilityProperty = dynamicProperties[calculatedReliabilityPropertyIndex];

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

            PropertyDescriptor convergenceProperty = dynamicProperties[convergencePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(convergenceProperty,
                                                                            resultCategory,
                                                                            "Convergentie",
                                                                            string.Empty,
                                                                            true);

            PropertyDescriptor calculateIllustrationPointsProperty = dynamicProperties[shouldCalculateIllustrationPointsIndex];

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

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[governingWindDirectionIndex],
                                                                            illustrationPointsCategory,
                                                                            "Maatgevende windrichting",
                                                                            "De windrichting waarvoor de berekende betrouwbaarheidsindex het laagst is.",
                                                                            true);

            PropertyDescriptor alphaValuesProperty = dynamicProperties[alphaValuesIndex];

            Assert.NotNull(alphaValuesProperty.Attributes[typeof(KeyValueElementAttribute)]);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(alphaValuesProperty,
                                                                            illustrationPointsCategory,
                                                                            "Invloedscoëfficiënten [-]",
                                                                            "Berekende invloedscoëfficiënten voor alle beschouwde stochasten.",
                                                                            true);

            PropertyDescriptor durationsProperty = dynamicProperties[durationsIndex];

            Assert.NotNull(durationsProperty.Attributes[typeof(KeyValueElementAttribute)]);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(durationsProperty,
                                                                            illustrationPointsCategory,
                                                                            "Tijdsduren [uur]",
                                                                            "Tijdsduren waarop de stochasten betrekking hebben.",
                                                                            true);

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[illustrationPointsIndex],
                                                                            illustrationPointsCategory,
                                                                            "Illustratiepunten",
                                                                            "De lijst van illustratiepunten voor de berekening.",
                                                                            true);
        }
        public void GetProperties_ValidData_ReturnsExpectedValues(bool withIllustrationPoints)
        {
            // Setup
            var random = new Random();

            double targetProbability     = random.NextDouble();
            double targetReliability     = random.NextDouble();
            double calculatedProbability = random.NextDouble();
            double calculatedReliability = random.NextDouble();
            double result      = random.NextDouble();
            var    convergence = random.NextEnumValue <CalculationConvergence>();

            var illustrationPoints = new[]
            {
                new TopLevelSubMechanismIllustrationPoint(new WindDirection("WEST", 4), "sluit", new TestSubMechanismIllustrationPoint())
            };
            var stochasts = new[]
            {
                new Stochast("a", 2, 3)
            };
            const string governingWindDirection = "EAST";
            GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult =
                withIllustrationPoints
                    ? new GeneralResult <TopLevelSubMechanismIllustrationPoint>(new WindDirection(governingWindDirection, 2),
                                                                                stochasts,
                                                                                illustrationPoints)
                    : null;

            var hydraulicBoundaryLocationCalculationOutput = new HydraulicBoundaryLocationCalculationOutput(result,
                                                                                                            targetProbability,
                                                                                                            targetReliability,
                                                                                                            calculatedProbability,
                                                                                                            calculatedReliability,
                                                                                                            convergence,
                                                                                                            generalResult);

            var calculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
            {
                Output = hydraulicBoundaryLocationCalculationOutput
            };

            // Call
            var properties = new TestHydraulicBoundaryLocationCalculationBaseProperties(calculation);

            // Assert
            Assert.AreEqual(targetProbability, properties.TargetProbability);
            Assert.AreEqual(targetReliability, properties.TargetReliability, properties.TargetReliability.GetAccuracy());
            Assert.AreEqual(calculatedProbability, properties.CalculatedProbability);
            Assert.AreEqual(calculatedReliability, properties.CalculatedReliability, properties.CalculatedReliability.GetAccuracy());
            Assert.AreEqual(convergence, properties.Convergence);
            Assert.AreEqual(calculation.InputParameters.ShouldIllustrationPointsBeCalculated, properties.ShouldIllustrationPointsBeCalculated);

            if (withIllustrationPoints)
            {
                GeneralResult <TopLevelSubMechanismIllustrationPoint> expectedGeneralResult = hydraulicBoundaryLocationCalculationOutput.GeneralResult;
                CollectionAssert.AreEqual(expectedGeneralResult.Stochasts, properties.AlphaValues);
                CollectionAssert.AreEqual(expectedGeneralResult.Stochasts, properties.Durations);
                CollectionAssert.AreEqual(expectedGeneralResult.TopLevelIllustrationPoints, properties.IllustrationPoints.Select(ip => ip.Data));
                Assert.AreEqual(expectedGeneralResult.GoverningWindDirection.Name, properties.GoverningWindDirection);
            }
        }
        public void Constructor_WithoutGeneralIllustrationPointsResult_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation());

            // Call
            var properties = new TestHydraulicBoundaryLocationCalculationBaseProperties(hydraulicBoundaryLocationCalculation);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(7, dynamicProperties.Count);

            const string resultCategory             = "Resultaat";
            const string illustrationPointsCategory = "Illustratiepunten";

            PropertyDescriptor resultProperty = dynamicProperties[resultPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(resultProperty,
                                                                            resultCategory,
                                                                            nameof(properties.Result),
                                                                            "",
                                                                            true);

            PropertyDescriptor targetProbabilityProperty = dynamicProperties[targetProbabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetProbabilityProperty,
                                                                            resultCategory,
                                                                            "Doelkans [1/jaar]",
                                                                            "De ingevoerde kans waarvoor het resultaat moet worden berekend.",
                                                                            true);

            PropertyDescriptor targetReliabilityProperty = dynamicProperties[targetReliabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetReliabilityProperty,
                                                                            resultCategory,
                                                                            "Betrouwbaarheidsindex doelkans [-]",
                                                                            "Betrouwbaarheidsindex van de ingevoerde kans waarvoor het resultaat moet worden berekend.",
                                                                            true);

            PropertyDescriptor calculatedProbabilityProperty = dynamicProperties[calculatedProbabilityPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedProbabilityProperty,
                                                                            resultCategory,
                                                                            "Berekende kans [1/jaar]",
                                                                            "De berekende kans van voorkomen van het berekende resultaat.",
                                                                            true);

            PropertyDescriptor calculatedReliabilityProperty = dynamicProperties[calculatedReliabilityPropertyIndex];

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

            PropertyDescriptor convergenceProperty = dynamicProperties[convergencePropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(convergenceProperty,
                                                                            resultCategory,
                                                                            "Convergentie",
                                                                            string.Empty,
                                                                            true);

            PropertyDescriptor calculateIllustrationPointsProperty = dynamicProperties[shouldCalculateIllustrationPointsIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculateIllustrationPointsProperty,
                                                                            illustrationPointsCategory,
                                                                            "Illustratiepunten inlezen",
                                                                            "Neem de informatie over de illustratiepunten op in het berekeningsresultaat.");
        }