/// <summary>
 /// Creates a new instance of <see cref="VariationCoefficientLogNormalDistributionProperties"/>.
 /// </summary>
 /// <param name="readOnlyProperties">Indicates which properties, if any, should be
 /// marked as read-only.</param>
 /// <param name="distribution">The <see cref="VariationCoefficientLogNormalDistribution"/> to create the properties for.</param>
 /// <param name="handler">Optional handler that is used to handle property changes.</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="distribution"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown when any number of properties in this class is editable and the
 /// <paramref name="handler"/> is <c>null</c>.</exception>
 public VariationCoefficientLogNormalDistributionProperties(
     VariationCoefficientDistributionReadOnlyProperties readOnlyProperties,
     VariationCoefficientLogNormalDistribution distribution,
     IObservablePropertyChangeHandler handler)
     : base(readOnlyProperties, distribution, handler)
 {
 }
 /// <summary>
 /// Creates a new <see cref="VariationCoefficientDesignVariableProperties{TDistribution}"/>.
 /// </summary>
 /// <param name="readOnlyProperties">Indicates which properties, if any, should be marked as read-only.</param>
 /// <param name="designVariable">The data of the <see cref="TDistribution"/> to create the properties for.</param>
 /// <param name="handler">The handler responsible for handling effects of a property change.</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="designVariable"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown when any number of properties in this class is editable and the
 /// <paramref name="handler"/> is <c>null</c>.</exception>
 protected VariationCoefficientDesignVariableProperties(VariationCoefficientDistributionReadOnlyProperties readOnlyProperties,
                                                        VariationCoefficientDesignVariable <TDistribution> designVariable,
                                                        IObservablePropertyChangeHandler handler)
     : base(readOnlyProperties, GetDistribution(designVariable), handler)
 {
     this.designVariable = designVariable;
 }
Exemple #3
0
 /// <summary>
 /// Creates a new <see cref="VariationCoefficientLogNormalDistributionDesignVariableProperties"/>.
 /// </summary>
 /// <param name="readOnlyProperties">Indicates which properties, if any, should be marked as read-only.</param>
 /// <param name="designVariable">The <see cref="DesignVariable{T}"/> to create the properties for.</param>
 /// <param name="handler">The handler responsible for handling effects of a property change.</param>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="designVariable"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown when any number of properties in this class is editable and the
 /// <paramref name="handler"/> is <c>null</c>.</exception>
 public VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionReadOnlyProperties readOnlyProperties,
                                                                          VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> designVariable,
                                                                          IObservablePropertyChangeHandler handler)
     : base(readOnlyProperties,
            designVariable,
            handler)
 {
 }
Exemple #4
0
        public void Constructor_NoDistributionSetWhileChangesPossible_ThrowArgumentException(
            VariationCoefficientDistributionReadOnlyProperties flags)
        {
            // Call
            TestDelegate call = () => new SimpleDistributionProperties(flags, null, null);

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

            Assert.AreEqual("distribution", paramName);
        }
Exemple #5
0
        public void Constructor_Always_PropertiesHaveExpectedAttributesValues(VariationCoefficientDistributionReadOnlyProperties readOnlyProperties, bool expectMeanReadOnly, bool expectCoefficientOfVariationReadOnly)
        {
            // Setup
            var mocks        = new MockRepository();
            var distribution = mocks.Stub <IVariationCoefficientDistribution>();
            var handler      = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            // Call
            var properties = new SimpleDistributionProperties(readOnlyProperties, distribution, handler);

            // Assert
            AssertPropertiesInState(properties, expectMeanReadOnly, expectCoefficientOfVariationReadOnly);
            mocks.VerifyAll();
        }
Exemple #6
0
        public void Constructor_NoHandlerSetWhileChangesPossible_ThrowArgumentException(
            VariationCoefficientDistributionReadOnlyProperties flags)
        {
            // Setup
            var mocks        = new MockRepository();
            var distribution = mocks.Stub <IVariationCoefficientDistribution>();

            mocks.ReplayAll();

            // Call
            TestDelegate call = () => new SimpleDistributionProperties(flags, distribution, null);

            // Assert
            const string message   = "Change handler required if changes are possible.";
            var          exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, message);

            Assert.AreEqual("handler", exception.ParamName);
            mocks.VerifyAll();
        }
Exemple #7
0
        /// <summary>
        /// Creates a new instance of <see cref="VariationCoefficientDistributionPropertiesBase{TDistribution}"/>.
        /// </summary>
        /// <param name="readOnlyProperties">Indicates which properties, if any, should be marked as read-only.</param>
        /// <param name="distribution">The data of the <see cref="TDistribution"/> to create the properties for.</param>
        /// <param name="handler">The handler responsible for handling effects of a property change.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="distribution"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when any number of properties in this class is editable and the
        /// <paramref name="handler"/> is <c>null</c>.</exception>
        protected VariationCoefficientDistributionPropertiesBase(
            VariationCoefficientDistributionReadOnlyProperties readOnlyProperties,
            TDistribution distribution,
            IObservablePropertyChangeHandler handler)
        {
            if (distribution == null)
            {
                throw new ArgumentNullException(nameof(distribution));
            }

            if (!readOnlyProperties.HasFlag(VariationCoefficientDistributionReadOnlyProperties.All) && handler == null)
            {
                throw new ArgumentException(@"Change handler required if changes are possible.", nameof(handler));
            }

            Data = distribution;

            isMeanReadOnly = readOnlyProperties.HasFlag(VariationCoefficientDistributionReadOnlyProperties.Mean);
            isVariationCoefficientReadOnly = readOnlyProperties.HasFlag(VariationCoefficientDistributionReadOnlyProperties.CoefficientOfVariation);

            changeHandler = handler;
        }
Exemple #8
0
        public void CoefficientOfVariation_ReadOnlyWithoutObserverable_ThrowsArgumentException(VariationCoefficientDistributionReadOnlyProperties readOnlyProperties)
        {
            // Setup
            var mocks        = new MockRepository();
            var distribution = mocks.Stub <IVariationCoefficientDistribution>();
            var handler      = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var properties = new SimpleDistributionProperties(readOnlyProperties, distribution, handler);

            // Call
            TestDelegate test = () => properties.CoefficientOfVariation = new RoundedDouble(2, 20);

            // Assert
            const string expectedMessage = "CoefficientOfVariation is set to be read-only.";
            string       actualMessage   = Assert.Throws <InvalidOperationException>(test).Message;

            Assert.AreEqual(expectedMessage, actualMessage);
            mocks.VerifyAll();
        }
Exemple #9
0
        public void DynamicReadOnlyValidationMethod_VariousReadOnlySet_ExpectedValues(VariationCoefficientDistributionReadOnlyProperties readOnlyProperties, bool expectMeanReadOnly, bool expectCoefficientOfVariationReadOnly)
        {
            // Setup
            var mocks        = new MockRepository();
            var distribution = mocks.Stub <IVariationCoefficientDistribution>();
            var handler      = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            var properties = new SimpleDistributionProperties(readOnlyProperties, distribution, handler);

            // Call
            bool meanIsReadOnly = properties.DynamicReadOnlyValidationMethod("Mean");
            bool coefficientOfVariationIsReadOnly = properties.DynamicReadOnlyValidationMethod("CoefficientOfVariation");
            bool doesNotExist = properties.DynamicReadOnlyValidationMethod("DoesNotExist");

            // Assert
            Assert.AreEqual(expectCoefficientOfVariationReadOnly, coefficientOfVariationIsReadOnly);
            Assert.AreEqual(expectMeanReadOnly, meanIsReadOnly);
            Assert.IsFalse(doesNotExist);
            mocks.VerifyAll();
        }