예제 #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);
        }
예제 #2
0
        public void PassTestMode()
        {
            DipeshLama_Spreadsheet_Assignment.FormulaClass f = new DipeshLama_Spreadsheet_Assignment.FormulaClass();
            List <double> values = new List <double> {
                2, 2, 3, 4, 2
            };
            double Result = f.Mode_Formula(values);

            Assert.AreEqual(2, Result);
        }
예제 #3
0
        public void FailTestMean2()
        {
            DipeshLama_Spreadsheet_Assignment.FormulaClass f = new DipeshLama_Spreadsheet_Assignment.FormulaClass();
            List <double> values = new List <double> {
                5, 5, 5, 5
            };
            double Result = f.Mean_Formula(values);

            Assert.AreEqual(10, Result);
        }
예제 #4
0
        public void FailTestSum2()
        {
            DipeshLama_Spreadsheet_Assignment.FormulaClass f = new DipeshLama_Spreadsheet_Assignment.FormulaClass();
            List <double> values = new List <double> {
                1, 2, 3, 4
            };
            double Result = f.Sum_Formula(values);

            Assert.AreEqual(50, Result);
        }
예제 #5
0
        public void FailTestMultiply()
        {
            DipeshLama_Spreadsheet_Assignment.FormulaClass f = new DipeshLama_Spreadsheet_Assignment.FormulaClass();
            List <double> values = new List <double> {
                5, 20
            };
            double Result = f.Multiply(values);

            Assert.AreEqual(200, Result);
        }
예제 #6
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);
        }