Exemple #1
0
        public double FunctionOperation(string calculation, IList <double> values)
        {
            double        result = 0;
            FormulaClass  fc     = new FormulaClass();
            List <double> value  = fc.SortedList(values);

            switch (calculation.ToLower())
            {
            case "sum":
                result = fc.Sum_Formula(value);
                break;

            case "median":
                result = fc.Median_Formula(value);
                break;

            case "mean":
                result = fc.Mean_Formula(value);
                break;

            case "mode":
                result = fc.Mode_Formula(value);
                break;

            case "average":
                result = fc.Average_Formula(value);
                break;

            case "*":
                result = fc.Multiply(value);
                break;
            }
            return(result);
        }
Exemple #2
0
        public void FailTestMedian2()
        {
            FormulaClass fc = new FormulaClass();

            DipeshLama_Spreadsheet_Assignment.FormulaClass f = new DipeshLama_Spreadsheet_Assignment.FormulaClass();
            List <double> values = new List <double> {
                1, 2, 4, 58, 42
            };
            List <double> sortedList = fc.SortedList(values);
            double        Result     = f.Median_Formula(sortedList);

            Assert.AreEqual(58, Result);
        }