public Student GetStudent(string id)
 {
     var errors = new List<string>();
     var repository = new StudentRepository();
     var service = new StudentService(repository);
     return service.GetStudent(id, ref errors);
 }
        public void StudentErrorTest()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);

            //// Act
            studentService.GetStudent(null, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Example #3
0
        public void GetStudent()
        {
            var errors = new List<string>();
            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);
            var student = new Student { StudentId = "aaaaaa", Email = "*****@*****.**" };
            var returnStudent = new Student();

            mockRepository.Setup(x => x.GetStudentDetail("aaaaaa", ref errors)).Returns(student);
            returnStudent = studentService.GetStudent("aaaaaa", ref errors);

            Assert.AreEqual("aaaaaa", returnStudent.StudentId);
            Assert.AreEqual("*****@*****.**", returnStudent.Email);
        }