Beispiel #1
0
        public void TestLowestGradeWithoutValues()
        {
            var book = new InMemoryBook("Gabriel's");

            void Act() => book.ComputeStatistics();

            var exception = Assert.Throws <Exception>((Action)Act);

            Assert.Equal("Grades is empty", exception.Message);
        }
Beispiel #2
0
        public void CanAddLetterGrade()
        {
            // arrange
            var book = new InMemoryBook("Letters");

            // act
            book.AddGrade('B');
            var stats = book.ComputeStatistics();

            // assert
            Assert.Equal(80, stats.Average);
        }
Beispiel #3
0
        public void GetALetter()
        {
            var book = new InMemoryBook("Gabriel's");

            book.AddGrade(92.1);
            book.AddGrade(99.3);
            book.AddGrade(87.2);

            var letter = book.ComputeStatistics().Letter;

            Assert.Equal('A', letter);
        }
Beispiel #4
0
        public void GetCLetter()
        {
            var book = new InMemoryBook("Gabriel's");

            book.AddGrade(70.1);
            book.AddGrade(80.3);
            book.AddGrade(71);

            var letter = book.ComputeStatistics().Letter;

            Assert.Equal('C', letter);
        }
Beispiel #5
0
        public void GetFLetter()
        {
            var book = new InMemoryBook("Gabriel's");

            book.AddGrade(33.1);
            book.AddGrade(60.3);
            book.AddGrade(21);

            var letter = book.ComputeStatistics().Letter;

            Assert.Equal('F', letter);
        }
Beispiel #6
0
        public void TestLowestGradeWithValues()
        {
            var book = new InMemoryBook("Gabriel's");

            book.AddGrade(29.3);
            book.AddGrade(41.8);
            book.AddGrade(79.2);
            book.AddGrade(63.1);

            var lowestGrade = book.ComputeStatistics().LowestGrade;

            Assert.Equal(29.3, lowestGrade);
        }
Beispiel #7
0
        public void TestComputeAverage()
        {
            var book = new InMemoryBook("Gabriel's");

            book.AddGrade(39.2);
            book.AddGrade(81.4);
            book.AddGrade(67.6);
            book.AddGrade(70);

            var average = book.ComputeStatistics().Average;

            Assert.Equal(64.55, average, 1);
        }
Beispiel #8
0
        public void ComputeStatistics()
        {
            // arrange
            var book = new InMemoryBook("Test Book");

            book.AddGrade(30.1);
            book.AddGrade(40.2);
            book.AddGrade(50.5);

            // act
            var stats = book.ComputeStatistics();

            // assert
            Assert.Equal(40.27, stats.Average, 2);
            Assert.Equal(30.1, stats.Low);
            Assert.Equal(50.5, stats.High);
            Assert.Equal('F', stats.Letter);
        }
Beispiel #9
0
        /* is an attribute - it is a little peace of data
         * that is attached to the following method. Xunit
         * looks for methods with this attribute to know which
         * methods is actual tests it should run. */
        public void BooksComputesAverageGrade()
        {
            // Unit testting is often divided into three parts: arrange, act
            //arrange - the setup for the test
            var book = new InMemoryBook("");

            book.AddGrade(90);
            book.AddGrade(60);
            book.AddGrade(20);


            // act - handling of the setup
            var result = book.ComputeStatistics();


            //assert - just assertion
            Assert.Equal(56.6, result.averageGrade, 0);
            Assert.Equal(20, result.lowestGrade);
            Assert.Equal(90, result.highestGrade);
            Assert.Equal('F', result.letterGrade);
        }