Example #1
0
        public void BookCalculatesStatistics()
        {
            var book = new DiskBook(_bookName);

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

            var result = book.GetStats();

            Assert.Equal(85.97, result.Average, 1);
            Assert.Equal(90.5, result.High, 1);
            Assert.Equal(77.3, result.Low, 1);
            Assert.Equal('B', result.Letter);
        }
Example #2
0
        public void DiskBookAddGradeArgumentException()
        {
            // Arrange
            var book = new DiskBook("Test's Book");

            // Assert & Act
            Assert.Throws <ArgumentException>(() => book.AddGrade(110.0));
        }
Example #3
0
        public void GradeAddedEventIsRaised()
        {
            var book = new DiskBook("test");

            book.GradeAdded += GradeAddedEventTest;
            book.AddGrade(10.0);
            Assert.True(EventCalled);
        }
Example #4
0
        public void BookCalculatesAnAverageGrade()
        {
            // arrange section
            var book = new DiskBook("");

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

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

            // assert section
            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);
        }
Example #5
0
        public void DiskBookCalculatesAnAverageGrade()
        {
            // Arrange
            var book = new DiskBook("Test's Book");

            book.AddGrade(76.3);
            book.AddGrade(84.7);
            book.AddGrade(92.6);

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

            // Assert
            Assert.Equal(84.5, result.Average, 1);
            Assert.Equal(92.6, result.High, 1);
            Assert.Equal(76.3, result.Low, 1);
            Assert.Equal('B', result.Letter);
        }
Example #6
0
        public void BookCalculatesStatisticsLetterGradeF()
        {
            var book = new DiskBook(_bookName);

            book.AddGrade(50.1);

            var result = book.GetStats();

            Assert.Equal('F', result.Letter);
        }
Example #7
0
        public void GetStatisticsTest()
        {
            // arrange
            var book = new DiskBook("new book");

            book.AddGrade(12.0);
            book.AddGrade(14.0);
            book.AddGrade(13.3);

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

            // assert
            Assert.Equal(12.0, result.Low, 1);
            Assert.Equal(14.0, result.High, 1);
            Assert.Equal(13.1, result.Average, 1);
            Assert.Equal('F', result.Letter);
            // terceiro argumento é a precisão de casas decimais
        }
Example #8
0
        public void AddGradeWhenLessThan100AndGreaterThan0()
        {
            var book = new DiskBook(_bookName);

            book.AddGrade(90);

            var grades = book.GetGrades();

            Assert.Equal(new List <double> {
                90
            }, grades);
            Assert.Single(grades);
        }
Example #9
0
        public void NoGradeAddedWhenGreaterThan100()
        {
            var book = new DiskBook(_bookName);

            try
            {
                book.AddGrade(395);
            }
            catch (Exception ex)
            {
                _testOutputHelper.WriteLine(ex.Message);
            }

            var grades = book.GetGrades();

            Assert.Empty(grades);
        }
Example #10
0
        public void DiskBookCalculatesAnAverageGrade()
        {
            //arrange
            var book = new DiskBook("ClassGrades\\ClassA.csv");

            book.AddGrade();

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

            // assert
            Assert.Equal(79.44444444444, result.Average, 1);
            Assert.Equal(9, result.originalStudents.Count);
            Assert.Single(result.discardedStudents);
            Assert.Equal(99, result.High);
            Assert.Equal(52, result.Low);
            Assert.All(result.discardedStudents, item => Assert.Contains("Edith Adkins", item.Name));
        }
Example #11
0
        public void GradeLessOrEqualtoOneHundred()
        {
            var book = new DiskBook("test");

            Assert.Throws <ArgumentException>(() => book.AddGrade(110.0));
        }
Example #12
0
        public void GradeGreaterThanOrEqualToZero()
        {
            var book = new DiskBook("test");

            Assert.Throws <ArgumentException>(() => book.AddGrade(-5.0));
        }