public List<Student> GetStudentList()
 {
     var errors = new List<string>();
     var repository = new StudentRepository();
     var service = new StudentService(repository);
     return service.GetStudentList(ref errors);
 }
コード例 #2
0
ファイル: StudentServiceTest.cs プロジェクト: fastily/cse136
        public void GetStudentList()
        {
            var errors = new List<string>();
            var mockRepository = new Mock<IStudentRepository>();
            var studentService = new StudentService(mockRepository.Object);
            var studentList = new List<Student>();
            var student1 = new Student { StudentId = "aaaaaa", Email = "*****@*****.**" };
            var student2 = new Student { StudentId = "bbbbbb", Email = "*****@*****.**" };
            var returnStudent = new List<Student>();

            studentList.Add(student1);
            studentList.Add(student2);

            mockRepository.Setup(x => x.GetStudentList(ref errors)).Returns(studentList);
            returnStudent = studentService.GetStudentList(ref errors);

            Assert.AreEqual(returnStudent.Count, 2);
        }