Exemplo n.º 1
0
        public void TestEmptyTableArth()
        {
            var calc = new AverageCalc();
            var emptyTable = new SubjectDetailsViewModel[1];
            var result = calc.Average(emptyTable);

        }
Exemplo n.º 2
0
        public void TestArthMean()
        {
            var rnd = new Random();
            List<SubjectDetailsViewModel> grades = new List<SubjectDetailsViewModel>();
            var sum = 0.0;
            for (var i = 0; i < 5; i++)
            {
                var val = rnd.Next(2, 6);
                var weight = rnd.Next(1, 10);
                var grade = new SubjectDetailsViewModel()
                {
                    grade_value = val,
                    grade_weight = weight
                };
                grades.Add(grade);
                sum += val;
            }
            var mean = Math.Round(sum/(grades.Count), 2);

            var calc = new AverageCalc();
            var result = calc.Average(grades.ToArray());

            Assert.AreEqual(mean, result);
        }