public void Repository_getClassAverageMarks()
        {
            //Arrange
            List <Student> students = new List <Student>
            {
                // StudentId, StudentName, Class, Subject, Marks
                new Student {
                    StudentId = 1, StudentName = "Ragav", Class = 10, Subject = "Computers", Marks = 89
                },
                new Student {
                    StudentId = 2, StudentName = "Charan", Class = 10, Subject = "Computers", Marks = 90
                },
                new Student {
                    StudentId = 3, StudentName = "Arjun", Class = 10, Subject = "Computers", Marks = 79
                },
                new Student {
                    StudentId = 4, StudentName = "Pavan", Class = 10, Subject = "Computers", Marks = 83
                },
                new Student {
                    StudentId = 5, StudentName = "Sudarshan", Class = 8, Subject = "Computers", Marks = 77
                },
                new Student {
                    StudentId = 6, StudentName = "Krish", Class = 9, Subject = "Computers", Marks = 89
                }
            };
            int classId         = 10;
            var studentsList    = students.Where(x => x.Class == 10).ToList();
            int studentsCount   = studentsList.Count();
            int totalClassMarks = studentsList.Sum(x => x.Marks);
            ServiceResponse <double> serviceResponse = new ServiceResponse <double>
            {
                Data = (totalClassMarks / studentsCount)
            };

            //Act
            A.CallTo(() => _studentDataRepository.getClassMarksAverageDetails(classId)).Returns(serviceResponse);
            ServiceResponse <double> classAverageMarks = _studentData.getClassMarksAverageDetails(classId);

            //Assert
            Assert.Equal(classAverageMarks, serviceResponse);
        }
Ejemplo n.º 2
0
 public ServiceResponse <double> getClassMarksAverageDetails(int classId)
 {
     return(_studentDataRepository.getClassMarksAverageDetails(classId));
 }