Пример #1
0
        public List<Enrollment> GetStudentEnrolledSchedulesByQuarter(string studentId, string year, string quarter)
        {
            var errors = new List<string>();
            var repository = new EnrollmentRepository(this.entities);
            var service = new EnrollmentService(repository);

            return service.GetStudentEnrolledSchedulesByQuarter(studentId, year, quarter, ref errors);
        }
Пример #2
0
        public Enrollment GetEnrollmentDetail(string studentId, int scheduleId)
        {
            var errors = new List<string>();
            var repository = new EnrollmentRepository(this.entities);
            var service = new EnrollmentService(repository);

            return service.GetEnrollmentDetail(studentId, scheduleId, ref errors);
        }
Пример #3
0
        public List<Enrollment> GetAllStudentEnrolledSchedules(string studentId)
        {
            var errors = new List<string>();
            var repository = new EnrollmentRepository(this.entities);
            var service = new EnrollmentService(repository);

            return service.GetAllStudentEnrolledSchedules(studentId, ref errors);
        }
Пример #4
0
        public void AddEnrollmentErrorTest3()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IEnrollmentRepository>();
            var enrollmentService = new EnrollmentService(mockRepository.Object);
            int? nullInt = null;
            //// Act
            enrollmentService.AddEnrollment("1", (int)nullInt, ref errors);

            //// Assert cant be null course object
            Assert.AreEqual(1, errors.Count);
        }
Пример #5
0
        public string AddEnrollment(Enrollment enrollment)
        {
            var errors = new List<string>();
            var repository = new EnrollmentRepository(this.entities);
            var service = new EnrollmentService(repository);
            service.AddEnrollment(enrollment.StudentId, enrollment.ScheduleId, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
Пример #6
0
        public void AddEnrollmentTest()
        {
            //// Arranage
            var errors = new List<string>();

            Mock<IEnrollmentRepository> mockRepository = new Mock<IEnrollmentRepository>();
            EnrollmentService iserv = new EnrollmentService(mockRepository.Object);

            Enrollment s = new Enrollment { StudentId = "99", ScheduleId = 1000, Grade = "A+", GradeValue = 3.0f };

            mockRepository.Setup(x => x.AddEnrollment("99", 1000, ref errors));
            mockRepository.Setup(x => x.IsNotDuplicateEnrollment("99", 1000, ref errors)).Returns(true);

            //// Act
            iserv.AddEnrollment("99", 1000, ref errors);

            //// Assert
            mockRepository.Verify(x => x.AddEnrollment("99", 1000, ref errors), Times.Once());
        }
Пример #7
0
        public void RemoveEnrollmentServiceTest()
        {
            //// Arrange
            var errors = new List<string>();

            Mock<IEnrollmentRepository> mockRepository = new Mock<IEnrollmentRepository>();
            EnrollmentService enrollservice = new EnrollmentService(mockRepository.Object);

            List<Enrollment> crl = new List<Enrollment>();
            crl.Add(new Enrollment { StudentId = "99", ScheduleId = 1000, Grade = "A+", GradeValue = 3.0f });

            mockRepository.Setup(x => x.RemoveEnrollment("99", 1000, ref errors));

            //// Act
            enrollservice.RemoveEnrollment("99", 1000, ref errors);

            //// Assert
            Assert.AreEqual(0, errors.Count);
            ////Assert.AreEqual(3, rating);
        }
Пример #8
0
        public void RemoveEnrollmentErrorTest1()
        {
            //// Arrange
            var errors = new List<string>();

            var mockRepository = new Mock<IEnrollmentRepository>();
            var enrollmentService = new EnrollmentService(mockRepository.Object);

            //// Act
            enrollmentService.RemoveEnrollment(string.Empty, 1, ref errors);

            //// Assert course id cannot be null
            Assert.AreEqual(1, errors.Count);
        }
Пример #9
0
        public List<Student> GetStudentsByScheduleId(int scheduleId)
        {
            var errors = new List<string>();
            var repository = new EnrollmentRepository(this.entities);
            var service = new EnrollmentService(repository);

            return service.GetStudentsByScheduleId(scheduleId, ref errors);
        }
Пример #10
0
        public string UpdateEnrollment(Enrollment er)
        {
            var errors = new List<string>();
            var repository = new EnrollmentRepository(this.entities);
            var service = new EnrollmentService(repository);

            service.UpdateEnrollment(er, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }