public void GetDesignValue_ValidLogNormalDistributionWithNonZeroShift_ReturnExpectedValue(
            double expectedValue, double variance, double shift, double percentile,
            double expectedResult)
        {
            // Setup
            const int numberOfDecimalPlaces = 4;
            var       logNormalDistribution = new VariationCoefficientLogNormalDistribution(numberOfDecimalPlaces)
            {
                Mean = (RoundedDouble)expectedValue,
                CoefficientOfVariation = (RoundedDouble)Math.Sqrt(variance),
                Shift = (RoundedDouble)shift
            };

            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(logNormalDistribution)
            {
                Percentile = percentile
            };

            // Call
            RoundedDouble result = designVariable.GetDesignValue();

            // Assert
            Assert.AreEqual(numberOfDecimalPlaces, result.NumberOfDecimalPlaces);
            Assert.AreEqual(expectedResult, result, result.GetAccuracy());
        }
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = new RoundedDouble(2, 1),
                CoefficientOfVariation = new RoundedDouble(2, 2)
            };
            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionReadOnlyProperties.None,
                                                                                                   designVariable,
                                                                                                   handler);

            // Assert
            Assert.AreEqual("Lognormaal", properties.DistributionType);
            Assert.AreEqual(distribution.Mean, properties.Mean);
            Assert.AreEqual(distribution.CoefficientOfVariation, properties.CoefficientOfVariation);
            Assert.AreEqual(designVariable.GetDesignValue(), properties.DesignValue);
        }
        public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution   = new VariationCoefficientLogNormalDistribution();
            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionReadOnlyProperties.None,
                                                                                                   designVariable,
                                                                                                   handler);

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

            Assert.AreEqual(4, dynamicProperties.Count);

            PropertyDescriptor distributionTypeProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(distributionTypeProperty,
                                                                            "Misc",
                                                                            "Type verdeling",
                                                                            "Het soort kansverdeling waarin deze parameter gedefinieerd wordt.",
                                                                            true);

            PropertyDescriptor meanProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(meanProperty,
                                                                            "Misc",
                                                                            "Verwachtingswaarde",
                                                                            "De gemiddelde waarde van de lognormale verdeling.");

            PropertyDescriptor standardDeviationProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(standardDeviationProperty,
                                                                            "Misc",
                                                                            "Variatiecoëfficiënt",
                                                                            "De variatiecoëfficiënt van de lognormale verdeling.");

            PropertyDescriptor designValueProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(designValueProperty,
                                                                            "Misc",
                                                                            "Rekenwaarde",
                                                                            "De representatieve waarde die gebruikt wordt door de berekening.",
                                                                            true);
            mockRepository.VerifyAll();
        }
        public void ParameteredConstructor_ValidLogNormalDistribution_ExpectedValues()
        {
            // Setup
            var logNormalDistribution = new VariationCoefficientLogNormalDistribution(2);

            // Call
            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(logNormalDistribution);

            // Assert
            Assert.IsInstanceOf <VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> >(designVariable);
            Assert.AreSame(logNormalDistribution, designVariable.Distribution);
            Assert.AreEqual(0.5, designVariable.Percentile);
        }
        public void SingleParameterConstructor_ExpectedValues()
        {
            // Setup
            var distribution   = new VariationCoefficientLogNormalDistribution();
            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(designVariable);

            // Assert
            Assert.IsInstanceOf <VariationCoefficientDesignVariableProperties <VariationCoefficientLogNormalDistribution> >(properties);
            Assert.AreSame(distribution, properties.Data);
            Assert.AreEqual(distribution.Mean, properties.Mean);
            Assert.AreEqual(distribution.CoefficientOfVariation, properties.CoefficientOfVariation);
            Assert.AreEqual("Lognormaal", properties.DistributionType);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution   = new VariationCoefficientLogNormalDistribution();
            var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionReadOnlyProperties.All,
                                                                                                   designVariable,
                                                                                                   handler);

            // Assert
            Assert.IsInstanceOf <VariationCoefficientDesignVariableProperties <VariationCoefficientLogNormalDistribution> >(properties);
            Assert.AreSame(distribution, properties.Data);
            Assert.AreEqual(distribution.Mean, properties.Mean);
            Assert.AreEqual(distribution.CoefficientOfVariation, properties.CoefficientOfVariation);
            Assert.AreEqual("Lognormaal", properties.DistributionType);
            mockRepository.VerifyAll();
        }