예제 #1
0
        public void ComputeStatisticsTest()
        {
            // arrange
            GradeBook book = new GradeBook();

            book.AddGrade(91);
            book.AddGrade(75);
            book.AddGrade(89.5f);
            // act
            GradeStatistics stats = book.ComputeStatistics();

            // assert
            stats.LowestGrade.ShouldBe(75);
            stats.HighestGrade.ShouldBe(91);
            stats.AverageGrade.ShouldBe(85.16666f, 0.005);
        }
        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);
        }
예제 #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 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 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);
        }
예제 #7
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.
        }
예제 #8
0
        public void ComputesAverageGradeFile()
        {
            Gradebook book = new Gradebook();

            book.AddGrade(70);
            book.AddGrade(78);
            book.AddGrade(90);
            //book.AddGrade(92);
            //book.AddGrade(93);

            //this is just to test "using". you can delete this test method
            using (StreamWriter ouputFile = File.CreateText("unitMetin" + "3" + ".txt"))
            {
                book.WriteGrades(ouputFile);
            }

            //ouputFile.Close();
            GradeStatistics stats = book.ComputeStatistics();

            Assert.AreEqual(79.33, stats.AverageGrade, 0.01);
        }
예제 #9
0
파일: UnitTest1.cs 프로젝트: PeddleM/Grades
 public UnitTest1()
 {
     book = new GradeBook();
     SetUpGrades();
     stats = book.ComputeStatistics();
 }
예제 #10
0
 public void ComputeWhenNoGrades()
 {
     GradeBook       grades = new GradeBook();
     GradeStatistics result = grades.ComputeStatistics();
 }
예제 #11
0
        public void ComputesAverage()
        {
            GradeStatistics stats = book.ComputeStatistics();

            Assert.AreEqual(50, stats.avgGrade, 0.01);
        }
예제 #12
0
        public void ComputesLowestGrade()
        {
            GradeStatistics stats = book.ComputeStatistics();

            Assert.AreEqual(10, stats.minGrade);
        }
예제 #13
0
        public void ComputesHighestGrade()
        {
            GradeStatistics stats = book.ComputeStatistics();

            Assert.AreEqual(90, stats.maxGrade);
        }
 public void TestCleanup()
 {
     this.book      = null;
     this.bookStats = null;
 }