Exemplo n.º 1
0
        public void AddValidGradeWithIF()
        {
            var b = new InMemoryBook("");

            b.AddGrade(150);

            //Assert.Equal("Invalid value", )
        }
Exemplo n.º 2
0
        public void DoWhile()
        {
            var b = new InMemoryBook("");

            b.AddGrade(150);

            //Assert.Equal("Invalid value", )
        }
Exemplo n.º 3
0
        public void BookCalculateStats()
        {
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);
            //do the stuff
            var result = book.GetStats();


            //test the stuff
            Assert.Equal(90.5, result.high, 1);
            Assert.Equal(77.3, result.low, 1);
            Assert.Equal(85.6, result.average, 1); // one decimal place
            Assert.Equal('B', result.letter);
        }
Exemplo n.º 4
0
        public void BookCalculatesAnAverageGrade()
        {
            //arrange
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);
            //act
            var result = book.getStatistics();

            //assert
            Assert.Equal(85.6, result.Average, 1);
            Assert.Equal(90.5, result.High, 1);
            Assert.Equal(77.3, result.Low, 1);
            Assert.Equal('B', result.Letter);
        }
Exemplo n.º 5
0
        public void BookCalculatesAnAverageGrade()
        {
            var book = new InMemoryBook("Colin's Grade Book");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);

            // act
            var Result = book.GetStatistics();

            // assert
            Assert.Equal(85.6, Result.Average, 1);
            Assert.Equal(90.5, Result.High, 1);
            Assert.Equal(77.3, Result.Low, 1);
            Assert.Equal('B', Result.Letter);
        }
Exemplo n.º 6
0
        public void BookCalculatesAnAvarageGrade()
        {
            //arrange
            var book = new InMemoryBook("");

            book.AddGrade(26.2);
            book.AddGrade(23.1);
            book.AddGrade(90.2);
            book.AddGrade(89.1);

            //act
            var result = book.GetStatistics();

            //asssert
            Assert.Equal(57.15, result.Avarage, 1);
            Assert.Equal(90.2, result.High);
        }
Exemplo n.º 7
0
        public void IsGradeAnCorrectValue()
        {
            var book = new InMemoryBook("");

            book.AddGrade(99.3);

            Assert.True(book.valuetest);
        }
Exemplo n.º 8
0
        public void Test1()
        {
            // Arrange
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);
            // Act
            var result = book.GetStatistics();

            // Assert
            Assert.Equal(90.5, result.High, 1);
            Assert.Equal(77.3, result.Low, 1);
            Assert.Equal(85.6, result.Average, 1);
            Assert.Equal('B', result.Letter);
        }
Exemplo n.º 9
0
        public void BookCalculatesCorrectGradesTest()
        {
            //arrange
            var book = new InMemoryBook("");

            book.AddGrade(98.3);
            book.AddGrade(85.4);
            book.AddGrade(90.6);

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

            Assert.Equal(98.3, stats.Highest);
            Assert.Equal(85.4, stats.Lowest);
            Assert.Equal(91, stats.Average, 0);
            Assert.Equal('A', stats.Letter);
        }
Exemplo n.º 10
0
        public void CheckAddGrade()
        {
            var book = new InMemoryBook("test");

            book.AddGrade(100);

            Assert.Contains(100, book.grades);
        }
Exemplo n.º 11
0
        public void CannotAddToBookOutsideRange()
        {
            //arrange
            var book = new InMemoryBook("test");

            try
            {
                //act
                book.AddGrade(104);
                book.AddGrade(-13);
            }
            catch (Exception ex)
            {
                // assert
                Assert.Equal("Invalid grade.", ex.Message);
            }
        }
Exemplo n.º 12
0
        public void BookCalculatesStats()
        {
            // arrange
            var book = new InMemoryBook("");

            book.AddGrade(34.34);
            book.AddGrade(33.12);
            book.AddGrade(32.12);
            // act
            var result = book.GetStatistics();

            // assert
            Assert.Equal(34.34, result.Highest);
            Assert.Equal(32.12, result.Lowest);
            Assert.Equal(33.19, result.Average, 2);
            Assert.Equal('F', result.Letter);
        }
Exemplo n.º 13
0
        public void BookCalulatesStatistics()
        {
            // arrange
            var book = new InMemoryBook("Tom's Book");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);

            // act
            var result = book.GetStatistics();

            // assert
            Assert.Equal(85.6, result.Average, 1);
            Assert.Equal(90.5, result.High, 1);
            Assert.Equal(77.3, result.Low, 1);
        }
Exemplo n.º 14
0
        public void BookCalculatesAnAverageGrade()
        {
            //Arrange
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);
            //Act
            var statistics = book.GetStatistics();

            //Assert
            Assert.Equal(85.6, statistics.GradeAverage(), 1);
            Assert.Equal(90.5, statistics.HighestGrade(), 1);
            Assert.Equal(77.3, statistics.LowestGrade(), 1);
            Assert.Equal('B', statistics.LetterAverageGrade());
        }
Exemplo n.º 15
0
        public void BookCalculatesAverageGrade()
        {
            // Arrange
            var book = new InMemoryBook("");

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

            // Act
            var results = book.GetStats();

            // Assert
            Assert.Equal(75, results.Average);
            Assert.Equal(90, results.High);
            Assert.Equal(60, results.Low);
            Assert.Equal('C', results.Letter);
        }
        public void BookCalculatesAnAverageGrade()
        {
            // arrange
            var book = new InMemoryBook("Scott");

            book.AddGrade(30);
            book.AddGrade(20);
            book.AddGrade(40);

            // act
            var result = book.GetStatistics();

            // assert
            Assert.Equal(30, result.Average);
            Assert.Equal(40, result.High);
            Assert.Equal(20, result.Low);
            Assert.Equal('F', result.Letter);
        }
Exemplo n.º 17
0
        public void BookCalculatesStats()
        {
            // Arrange
            var book = new InMemoryBook("");

            book.AddGrade(95.7);
            book.AddGrade(70.2);
            book.AddGrade(54.7);

            // Act
            var result = book.GetStatistics();

            // Assert
            Assert.Equal(54.7, result.Low);
            Assert.Equal(95.7, result.High);
            Assert.Equal(73.5, result.Average, 1);
            Assert.Equal('C', result.Letter);
        }
Exemplo n.º 18
0
        public void BookCalculateAverageGrade()
        {
            //* arrange
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);

            //* act
            var results = book.GetStatistics();

            //* assert
            Assert.Equal(85.6, results.Average, 1);
            Assert.Equal('B', results.Letter);
            Console.WriteLine($"The highgrade is: {results.High}\nThe lowest Grade is: {results.Low}");
            Console.WriteLine($"The average in the grade is {results.Average:N1}");
        }
Exemplo n.º 19
0
        public void BookCalculatesStatistis()
        {
            // arrange
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);

            // act
            var actual = book.GetStatistics();

            // assert
            Assert.Equal(85.6, actual.Avarage, 1);
            Assert.Equal(90.5, actual.High, 2);
            Assert.Equal(77.3, actual.Low, 2);
            Assert.Equal('B', actual.Letter);
        }
Exemplo n.º 20
0
        public void CannotAddGreaterGrade()
        {
            InMemoryBook book1 = GetBook("Book 1");

            book1.AddGrade(105);
            var x = book1.GetStatistics();

            Assert.NotEqual(x.High, 105);
        }
Exemplo n.º 21
0
        public void BookCalculatesAnAverageGrade()
        {
            // arrange
            var book = new InMemoryBook("");

            book.AddGrade(82.2);
            book.AddGrade(90.4);
            book.AddGrade(45);

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

            // assert
            Assert.Equal(72.5, stats.Average, 1);
            Assert.Equal(90.4, stats.High);
            Assert.Equal(45, stats.Low);
            Assert.Equal('C', stats.Letter);
        }
Exemplo n.º 22
0
        public void BookCalculatesAnAverageGrade()
        {
            InMemoryBook book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);
            double expectedAverage = 85.6;
            double expectedHigh    = 90.5;
            double expectedLow     = 77.3;

            Statistics result = book.GetStatistics();

            Assert.Equal(expectedAverage, result.Average, 1);
            Assert.Equal(expectedHigh, result.High, 1);
            Assert.Equal(expectedLow, result.Low, 1);
            Assert.Equal('B', result.Letter);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
0
        public void CannotAddInvalidLetterGrade()
        {
            // arrange
            var book = new InMemoryBook("Test Book");

            // act / assert
            Assert.Throws <ArgumentException>(() => book.AddGrade('/'));
            Assert.False(book.HasGrades);
        }
Exemplo n.º 25
0
        public void AddGradeVerifysInput()
        {
            //arrange
            var          lowGradeInput  = -1.5;
            var          highGradeInput = 101.8;
            var          validInput     = 90.5;
            InMemoryBook book           = new InMemoryBook("Test Book");

            //act
            var case1 = book.AddGrade(lowGradeInput);
            var case2 = book.AddGrade(highGradeInput);
            var case3 = book.AddGrade(validInput);

            //assert
            Assert.Equal(false, case1);
            Assert.Equal(false, case2);
            Assert.Equal(true, case3);
        }
Exemplo n.º 26
0
        public void BookCalculatesAnAverageGrade()
        {
            //arrange
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);

            //actual
            var statistics = book.GetStatistics();

            //assert
            Assert.Equal(85.6, Math.Round(statistics.Average, 1));             //round only one decimal
            Assert.Equal(90.5, statistics.High);
            Assert.Equal(77.3, statistics.Low);
            Assert.Equal('B', statistics.Letter);
        }
Exemplo n.º 27
0
        public void BookCalculateGradeStats()
        {
            // Arrange
            var book = new InMemoryBook("");

            book.AddGrade(90.1);
            book.AddGrade(75.2);
            book.AddGrade(45.6);

            // Act
            var result = book.GetStatistics();

            // Assert
            Assert.Equal(70.3, result.Average, 1);
            Assert.Equal(90.1, result.High, 1);
            Assert.Equal(45.6, result.Low, 1);
            Assert.Equal('C', result.Letter);
        }
Exemplo n.º 28
0
        public void BookCalculatesAnAverageGrade()
        {
            // arrange section
            var book = new InMemoryBook("");

            book.AddGrade(12.3);
            book.AddGrade(10.2);
            book.AddGrade(9.4);

            // act section
            var result = book.GetStatistics();

            // assert section
            Assert.Equal(10.6, result.average, 1);
            Assert.Equal(9.4, result.low, 1);
            Assert.Equal(12.3, result.high, 1);
            Assert.Equal('F', result.letter);
        }
Exemplo n.º 29
0
        public void BookReturnsAverageGrade()
        {
            // arrange
            var book = new InMemoryBook("Test Book");

            book.AddGrade(99.9);
            book.AddGrade(49.3);
            book.AddGrade(39.3);
            book.AddGrade(29.3);
            book.AddGrade(19.3);
            var expected = 47.42;

            // act
            var actual = book.GetGradeAverage();

            // assert
            Assert.Equal(actual, expected);
        }
Exemplo n.º 30
0
        public void BookCalculatesAverageGrade()
        {
            // arrange section, put together test data
            var book = new InMemoryBook("");

            book.AddGrade(89.1);
            book.AddGrade(90.5);
            book.AddGrade(77.3);

            // act, invoke method to perform actual result
            var result = book.GetStats();

            // assert, test
            Assert.Equal(85.6, result.Average, 1);
            Assert.Equal(90.5, result.High, 1);
            Assert.Equal(77.3, result.Low, 1);
            Assert.Equal('B', result.Letter);
        }