示例#1
0
        public void IncorrectGradesAreRejected()
        {
            //* Arrange *//
            var book = new InMemoryBook("Test Book");

            //* Act *//
            // Singles
            book.AddGrade(-0.1);
            book.AddGrade(100.1);
            book.AddGrade("abc");

            // Lists
            book.AddGrades(new List <double>()
            {
                -0.1, 100.1
            });
            book.AddGrades(new List <string>()
            {
                "A", "b", "c"
            });

            // Arrays
            book.AddGrades(new double[] { -0.1, 100.1 });
            book.AddGrades(new string[] { "abc" });

            //* Assert *//
            Assert.Equal(0, book.Grades.Count);
        }
示例#2
0
        public void CorrectListGradesAreAdded()
        {
            //* Arrange *//
            var book = new InMemoryBook("Test Book");

            //* Act *//
            // Double
            book.AddGrades(new List <double>()
            {
                -0.0, 0.0, 100.0
            });
            // Int
            book.AddGrades(new List <int>()
            {
                -0, 0, 100
            });
            // String
            book.AddGrades(new List <string>()
            {
                "-0.0", "0.0", "100.0"
            });
            book.AddGrades(new List <string>()
            {
                "-0.0", "0", "100.0"
            });
            // Letters
            book.AddGrades(new List <char>()
            {
                'a', 'b', 'c', 'A', 'B', 'C'
            });

            //* Assert *//
            Assert.Equal(18, book.Grades.Count);
            Assert.Equal(48.9, book.GetStatistics().Average, 1);
        }
示例#3
0
        public void Test1()
        {
            //Arrange
            var book = new InMemoryBook("");

            book.AddGrades(93.2);
            book.AddGrades(88.2);
            book.AddGrades(63.2);
            //Act

            var result = book.GetStatistics();

            //Assert

            Assert.Equal(81.5, result.Average, 1);
            Assert.Equal(63.2, result.Low, 1);
            Assert.Equal(93.2, result.High, 1);
            Assert.Equal('B', result.GBA);
        }
示例#4
0
        public void CorrectArrayGradesAreAdded()
        {
            //* Arrange *//
            var book = new InMemoryBook("Test Book");

            //* Act *//
            // Double
            book.AddGrades(new double[] { -0.0, 0.0, 100.0 });
            // Int
            book.AddGrades(new int[] { -0, 0, 100 });
            // String
            book.AddGrades(new string[] { "-0.0", "0.0", "100.0" });
            book.AddGrades(new string[] { "-0.0", "0", "100.0" });


            //* Assert *//
            Assert.Equal(12, book.Grades.Count);
            Assert.Equal(33.3, book.GetStatistics().Average, 1);
        }