public void ToString_Always_ReturnDistributionName()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution = new LogNormalDistribution(2)
            {
                Mean = new RoundedDouble(2, 1),
                StandardDeviation = new RoundedDouble(2, 2),
                Shift             = new RoundedDouble(2, 0.3)
            };
            var designVariable = new LogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new ShiftedLogNormalDistributionDesignVariableProperties(DistributionReadOnlyProperties.None,
                                                                                      designVariable,
                                                                                      handler);

            // Call
            string propertyName = properties.ToString();

            // Assert
            Assert.AreEqual("0,53 (Verwachtingswaarde = 1,00, Standaardafwijking = 2,00, Verschuiving = 0,30)", propertyName);
        }
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution = new LogNormalDistribution(2)
            {
                Mean = new RoundedDouble(2, 1),
                StandardDeviation = new RoundedDouble(2, 2)
            };
            var designVariable = new LogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new ShiftedLogNormalDistributionDesignVariableProperties(DistributionReadOnlyProperties.None,
                                                                                      designVariable,
                                                                                      handler);

            // Assert
            Assert.AreEqual("Lognormaal", properties.DistributionType);
            Assert.AreEqual(distribution.Mean, properties.Mean);
            Assert.AreEqual(distribution.StandardDeviation, properties.StandardDeviation);
            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 LogNormalDistribution();
            var designVariable = new LogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new ShiftedLogNormalDistributionDesignVariableProperties(DistributionReadOnlyProperties.None,
                                                                                      designVariable,
                                                                                      handler);

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

            Assert.AreEqual(5, 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",
                                                                            "Standaardafwijking",
                                                                            "De standaardafwijking van de lognormale verdeling.");

            PropertyDescriptor shiftProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(shiftProperty,
                                                                            "Misc",
                                                                            "Verschuiving",
                                                                            "De hoeveelheid waarmee de kansverdeling naar rechts (richting van positieve X-as) verschoven is.",
                                                                            true);

            PropertyDescriptor designValueProperty = dynamicProperties[4];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(designValueProperty,
                                                                            "Misc",
                                                                            "Rekenwaarde",
                                                                            "De representatieve waarde die gebruikt wordt door de berekening.",
                                                                            true);
            mockRepository.VerifyAll();
        }
Beispiel #4
0
        public void GetDesignValue_ValidLogNormalDistributionWithNonZeroShift_ReturnExpectedValue(
            double expectedValue, double variance, double shift, double percentile,
            double expectedResult)
        {
            // Setup
            const int numberOfDecimalPlaces = 4;
            var       logNormalDistribution = new LogNormalDistribution(numberOfDecimalPlaces)
            {
                Mean = (RoundedDouble)expectedValue,
                StandardDeviation = (RoundedDouble)Math.Sqrt(variance),
                Shift             = (RoundedDouble)shift
            };

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

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

            // Assert
            Assert.AreEqual(numberOfDecimalPlaces, result.NumberOfDecimalPlaces);
            Assert.AreEqual(expectedResult, result, result.GetAccuracy());
        }
Beispiel #5
0
        public void ParameteredConstructor_ValidLogNormalDistribution_ExpectedValues()
        {
            // Setup
            var logNormalDistribution = new LogNormalDistribution(2);

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

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

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

            // Assert
            Assert.IsInstanceOf <LogNormalDistributionDesignVariableProperties>(properties);
            Assert.AreSame(distribution, properties.Data);
            Assert.AreEqual(distribution.Mean, properties.Mean);
            Assert.AreEqual(distribution.StandardDeviation, properties.StandardDeviation);
            Assert.AreEqual("Lognormaal", properties.DistributionType);
        }
Beispiel #7
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution   = new LogNormalDistribution();
            var designVariable = new LogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new SimpleDesignVariableProperties(DistributionReadOnlyProperties.All,
                                                                designVariable,
                                                                handler);

            // Assert
            Assert.IsInstanceOf <DistributionPropertiesBase <LogNormalDistribution> >(properties);
            Assert.AreEqual(designVariable.GetDesignValue(), properties.DesignValue);
            mockRepository.VerifyAll();
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution   = new LogNormalDistribution();
            var designVariable = new LogNormalDistributionDesignVariable(distribution);

            // Call
            var properties = new ShiftedLogNormalDistributionDesignVariableProperties(DistributionReadOnlyProperties.All,
                                                                                      designVariable,
                                                                                      handler);

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