Example #1
0
        public async Task GetStudentRecords_Should()
        {
            var studentRecords = new List <StudentRecordDTO>();
            var studentCourses = new List <StudentCourseDTO>();
            var studentCourse  = new StudentCourseDTO()
            {
                CourseId    = 5,
                CourseTitle = "Microsoft SQL Server Database Development"
            };

            studentCourses.Add(studentCourse);
            var studentExams = new List <StudentExamDTO>();
            var studentExam  = new StudentExamDTO()
            {
                ExamId    = 6,
                ExamTitle = "Microsoft SQL Server 2008, Database Development"
            };

            studentExams.Add(studentExam);
            var studentCertifications = new List <StudentCertificationDTO>();
            var studentCertification  = new StudentCertificationDTO()
            {
                CertificationId    = 5,
                CertificationTitle = "Microsoft Certified Technical Specialist in SQL Server 2008, Database Development"
            };

            studentCertifications.Add(studentCertification);
            var studentRecord = new StudentRecordDTO()
            {
                StudentId      = 1,
                FirstName      = "Steve",
                LastName       = "Miazga",
                Email          = "*****@*****.**",
                Courses        = studentCourses,
                Exams          = studentExams,
                Certifications = studentCertifications
            };

            studentRecords.Add(studentRecord);

            _mockQueryRepository.Setup(x => x.GetStudentRecords(0)).Returns(studentRecords);

            var query   = new GetStudentRecordsQuery();
            var handler = new GetStudentRecordsQueryHandler(_mockQueryRepository.Object);
            var result  = await handler.Handle(query, CancellationToken.None);

            Assert.NotNull(result);
        }
        public Task <List <StudentRecordDTO> > Handle(GetStudentRecordsQuery request, CancellationToken cancellationToken)
        {
            var studentRecords = _queryRepository.GetStudentRecords();

            return(Task.FromResult(studentRecords));
        }