Esempio n. 1
0
        public void Add_ShouldComputeTheAdmissionGradeAndAddTheStudentToTheDb()
        {
            //Arrange
            var mockIAdmissionGradesManager = new Mock <IAdmissionGradesManager>();
            var student = new Student {
                Cnp = 1, FirstName = "John"
            };
            var students = new List <Student> {
                student
            };
            var admissionGrade = 8.5;

            mockIAdmissionGradesManager.Setup(manager => manager.GetAdmissionGrade(student)).Returns(admissionGrade);
            var studentsController = new StudentsController(mockIAdmissionGradesManager.Object);

            //Act
            studentsController.Add(students);

            //Assert
            mockIAdmissionGradesManager.Verify(manager => manager.GetAdmissionGrade(student), Times.Once());
            Assert.AreEqual(admissionGrade, student.AdmissionGrade);
        }