public void UpdateGradeChangeRequestTest2() { // Arrange var errors = new List<string>(); var mockRepository = new Mock<IStudentRepository>(); var studentService = new StudentService(mockRepository.Object); var enrollments = new List<Enrollment>(); enrollments.Add(new Enrollment { Grade = "A", GradeValue = 4.0f, ScheduleId = 1, StudentId = "testId" }); mockRepository.Setup(x => x.GetEnrollments("testId")).Returns(enrollments); // Act studentService.UpdateGradeChangeRequest("testId", 1, true, ref errors); studentService.UpdateGradeChangeRequest("testId", 1, false, ref errors); // Assert Assert.AreEqual(0, errors.Count); }
public string UpdateGradeChangeRequest(string studentId, int scheduleId, bool requestChange) { var errors = new List<string>(); var repository = new StudentRepository(); var service = new StudentService(repository); service.UpdateGradeChangeRequest(studentId, scheduleId, requestChange, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void UpdateGradeChangeRequestTest() { // Arrange var errors = new List<string>(); var mockRepository = new Mock<IStudentRepository>(); var studentService = new StudentService(mockRepository.Object); // Act studentService.UpdateGradeChangeRequest(string.Empty, 0, true, ref errors); // Assert Assert.AreEqual(1, errors.Count); }