Example #1
0
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

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

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

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

            mockRepository.ReplayAll();

            var distribution   = new NormalDistribution();
            var designVariable = new NormalDistributionDesignVariable(distribution);

            // Call
            var properties = new NormalDistributionDesignVariableProperties(DistributionReadOnlyProperties.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 normale verdeling.");

            PropertyDescriptor standardDeviationProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(standardDeviationProperty,
                                                                            "Misc",
                                                                            "Standaardafwijking",
                                                                            "De standaardafwijking van de normale verdeling.");

            PropertyDescriptor designValueProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(designValueProperty,
                                                                            "Misc",
                                                                            "Rekenwaarde",
                                                                            "De representatieve waarde die gebruikt wordt door de berekening.",
                                                                            true);
            mockRepository.VerifyAll();
        }
Example #3
0
        public void ParameteredConstructor_ValidNormalDistribution_ExpectedValues()
        {
            // Setup
            var normalDistribution = new NormalDistribution(3);

            // Call
            var designVariable = new NormalDistributionDesignVariable(normalDistribution);

            // Assert
            Assert.IsInstanceOf <PercentileBasedDesignVariable <NormalDistribution> >(designVariable);
            Assert.AreSame(normalDistribution, designVariable.Distribution);
            Assert.AreEqual(0.5, designVariable.Percentile);
        }
Example #4
0
        public void GetDesignValue_ValidNormalDistribution_ReturnExpectedValue(
            double expectedValue, double variance, double percentile,
            double expectedResult)
        {
            // Setup
            var normalDistribution = new NormalDistribution(4)
            {
                Mean = (RoundedDouble)expectedValue,
                StandardDeviation = (RoundedDouble)Math.Sqrt(variance)
            };

            var designVariable = new NormalDistributionDesignVariable(normalDistribution)
            {
                Percentile = percentile
            };

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

            // Assert
            Assert.AreEqual(expectedResult, result, 1e-4);
        }
Example #5
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var mockRepository = new MockRepository();
            var handler        = mockRepository.Stub <IObservablePropertyChangeHandler>();

            mockRepository.ReplayAll();

            var distribution   = new NormalDistribution();
            var designVariable = new NormalDistributionDesignVariable(distribution);

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

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