Пример #1
0
 /// <summary>
 /// Attempts to set the parameters of an <see cref="IVariationCoefficientDistribution"/>.
 /// </summary>
 /// <param name="distribution">The <see cref="IVariationCoefficientDistribution"/> to be updated.</param>
 /// <param name="configuration">The configuration containing the new values for
 /// <see cref="IVariationCoefficientDistribution.Mean"/> and <see cref="IVariationCoefficientDistribution.CoefficientOfVariation"/>.</param>
 /// <param name="stochastName">The descriptive name of <paramref name="distribution"/>.</param>
 /// <param name="calculationName">The name of the calculation to which <paramref name="distribution"/>
 /// is associated.</param>
 /// <returns><c>true</c> if setting all properties was successful, <c>false</c> otherwise.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="distribution"/>
 /// is <c>null</c>.</exception>
 public static bool TrySetDistributionProperties(this IVariationCoefficientDistribution distribution,
                                                 StochastConfiguration configuration,
                                                 string stochastName, string calculationName)
 {
     return(distribution.TrySetMean(configuration.Mean, stochastName, calculationName) &&
            distribution.TrySetVariationCoefficient(configuration.VariationCoefficient, stochastName, calculationName));
 }
Пример #2
0
 /// <summary>
 /// Attempts to set the parameters of an <see cref="IVariationCoefficientDistribution"/>.
 /// </summary>
 /// <param name="distribution">The <see cref="IVariationCoefficientDistribution"/> to be updated.</param>
 /// <param name="mean">The new value for <see cref="IVariationCoefficientDistribution.Mean"/>.</param>
 /// <param name="variationCoefficient">The new value for <see cref="IVariationCoefficientDistribution.CoefficientOfVariation"/>.</param>
 /// <param name="stochastName">The descriptive name of <paramref name="distribution"/>.</param>
 /// <param name="calculationName">The name of the calculation to which <paramref name="distribution"/>
 /// is associated.</param>
 /// <returns><c>true</c> if setting all properties was successful, <c>false</c> otherwise.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="distribution"/>
 /// is <c>null</c>.</exception>
 public static bool TrySetDistributionProperties(this IVariationCoefficientDistribution distribution,
                                                 double?mean, double?variationCoefficient,
                                                 string stochastName, string calculationName)
 {
     return(distribution.TrySetMean(mean, stochastName, calculationName) &&
            distribution.TrySetVariationCoefficient(variationCoefficient, stochastName, calculationName));
 }
Пример #3
0
        public void TrySetMean_VariationCoefficientDistributionNull_ThrownArgumentNullException()
        {
            // Setup
            IVariationCoefficientDistribution distribution = null;

            const double mean = 1.1;

            // Call
            TestDelegate call = () => distribution.TrySetMean(mean, "A", "B");

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

            Assert.AreEqual("distribution", paramName);
        }