public string UpdateStudent(Student student) { var errors = new List<string>(); var repository = new StudentRepository(this.entities); var service = new StudentService(repository); service.UpdateStudent(student, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void UpdateStudentErrorTest() { //// Arrange var errors = new List<string>(); var mockRepository = new Mock<IStudentRepository>(); var studentService = new StudentService(mockRepository.Object); //// Act studentService.UpdateStudent(null, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public void UpdateStudentErrorTest4() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<IStudentRepository>(); var studentService = new StudentService(mockRepository.Object); var student = new Student { StudentId = "aaaaaa", Email = "c@c" }; //// Act studentService.UpdateStudent(student, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public void UpdateStudent() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<IStudentRepository>(); var studentService = new StudentService(mockRepository.Object); var student = new Student { StudentId = "aaaaaa", Email = "*****@*****.**" }; mockRepository.Setup(x => x.UpdateStudent(student, ref errors)); //// Act studentService.UpdateStudent(student, ref errors); //// Assert mockRepository.Verify(x => x.UpdateStudent(student, ref errors), Times.Once()); }