public void ComputeHighestGrade()
        {
            GradeBook book  = new GradeBook();
            GradeBook book2 = new GradeBook();

            book.AddGrade(10);
            book.AddGrade(90);
            book2.AddGrade(100);

            //making a gradestatistics object calling it result and invoking a method of compute statistics
            GradeStatistics result  = book.ComputeStatistics();
            GradeStatistics result2 = book2.ComputeStatistics();

            //aserting that the highest grade is in act the highest grade
            Assert.AreEqual(90, result.HighestGrade);
            Assert.AreNotEqual(result.HighestGrade, result2.HighestGrade);
        }
        public void ComputesLowestGrade()
        {
            GradeBook book = new GradeBook();

            book.AddGrade(10);
            book.AddGrade(75);
            book.AddGrade(68);
            book.AddGrade(84);
            book.AddGrade(45);
            book.AddGrade(82);
            book.AddGrade(90);

            GradeStatistics results = book.ComputeStatistics();

            Assert.AreEqual(results.lowestGrade, 10);
        }
Beispiel #3
0
        public void ComputesAverageGrade()
        {
            GradeBook book = new GradeBook();

            book.AddGrade(91);
            book.AddGrade(89.5f);
            book.AddGrade(75);
            book.AddGrade(70);
            book.AddGrade(80);
            book.AddGrade(30);
            book.AddGrade(50);

            GradeStatistics result = book.ComputeStatistics();

            Assert.AreEqual(69.35, result.AverageGrade, 0.01);
        }
        public void ComputesAverageGrade()
        {
            GradeBook book = new GradeBook();

            book.AddGrade(10);
            book.AddGrade(75);
            book.AddGrade(68);
            book.AddGrade(84);
            book.AddGrade(45);
            book.AddGrade(82);
            book.AddGrade(90);

            GradeStatistics results = book.ComputeStatistics();

            // Typically with Test methods that check equality, there is a parameter that allows you to check for equality
            // within a specified amount. Here, we want to check equality within 0.01
            Assert.AreEqual(results.avgGrade, 64.85, 0.01);
        }
        public void ComputesHighestGrade()
        {
            // Create a new GradeBook for testing and add some grades to it
            GradeBook book = new GradeBook();

            book.AddGrade(10);
            book.AddGrade(75);
            book.AddGrade(68);
            book.AddGrade(84);
            book.AddGrade(45);
            book.AddGrade(82);
            book.AddGrade(90);

            // Compute some statistics on the GradeBook and store the results
            GradeStatistics results = book.ComputeStatistics();

            // Check if the highest grade in the results is the correct value (90)
            Assert.AreEqual(results.highestGrade, 90);
        }
Beispiel #6
0
        public void ComputeStatistics()
        {
            GradeBook book = new GradeBook();

            var test = new List <float>()
            {
                10f, 66f, 99f
            };

            foreach (float grade in test)
            {
                book.AddGrade(grade);
            }

            GradeStatistics result = book.ComputeStatistics();

            Assert.AreEqual(test.Max(), result.highest);
            Assert.AreEqual(test.Min(), result.lowest);
            Assert.AreEqual(test.Average(), result.average, 0.01);
            //the third parameter is a delta.
        }
Beispiel #7
0
 private void SetUpGrades()
 {
     book.AddGrade(80f);
     book.AddGrade(72.5f);
     book.AddGrade(65f);
 }
Beispiel #8
0
 public GradeBookTests()
 {
     book.AddGrade(10);
     book.AddGrade(90);
 }