public void InsertStudentErrorTest() { //// Arrange var errors = new List<string>(); var mockRepository = new Mock<IStudentRepository>(); var studentService = new StudentService(mockRepository.Object); //// Act studentService.InsertStudent(null, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public string InsertStudent(Student student) { var errors = new List<string>(); var repository = new StudentRepository(this.entities); var service = new StudentService(repository); service.InsertStudent(student, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void InsertStudentErrorTest4() { //// 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.InsertStudent(student, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public void InsertStudent() { //// 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.InsertStudent(student, ref errors)); //// Act studentService.InsertStudent(student, ref errors); //// Assert mockRepository.Verify(x => x.InsertStudent(student, ref errors), Times.Once()); }