Exemplo n.º 1
0
        public void GeometricMeanTest(double firstValue, double secondValue, double expected)
        {
            var calculator   = new GeometricMeanCalculator();
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult);
        }
Exemplo n.º 2
0
        public void ExceptionTest()
        {
            var calculator = new GeometricMeanCalculator();

            Assert.Throws <Exception>(() => calculator.Calculate(-1, -1));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Calculates the geometric mean of the given numbers.
 /// </summary>
 /// <param name="numbers">The numbers whose geometric mean is to be calculated.</param>
 /// <returns>The geometric mean of the given numbers.</returns>
 /// <exception cref="System.InvalidOperationException">
 /// The collection must not contain negative numbers and must not be empty.
 /// </exception>
 /// <exception cref="System.ArgumentNullException">
 /// The specified collection must not be null.
 /// </exception>
 public static double GeometricMean(this IEnumerable <double> numbers)
 {
     return(GeometricMeanCalculator.GeometricMean(numbers));
 }