public string ApproveGradeChange(GradeChange gc)
        {
            var errors = new List<string>();
            var repository = new GradeChangeRepository(this.entities);
            var service = new GradeChangeService(repository);
            service.ApproveGradeChange(gc, ref errors);

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

            return "error";
        }
        public void RespondToGradeChageTestError1()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IGradeChangeRepository>();
            var gradeChangeService = new GradeChangeService(mockRepository.Object);
            var gc = new GradeChange { Course_id = -1 };

            //// Act
            gradeChangeService.ApproveGradeChange(gc, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
Exemple #3
0
        public void ApproveGradeChange(GradeChange gc, ref List<string> errors)
        {
            if (gc.Course_id == -1)
            {
                errors.Add("Invalid course ID");
                throw new ArgumentException();
            }

            this.repository.ApproveGradeChange(gc.GradeChangeId, ref errors);

            if (errors.Count != 0)
            {
                errors.Add("Invalid schedule ID");
                throw new ArgumentException();
            }
        }
        public void RespondToGradeChageTest()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IGradeChangeRepository>();
            var gradeChangeService = new GradeChangeService(mockRepository.Object);
            var gc = new GradeChange { Course_id = 5, GradeChangeId = 1 };

            mockRepository.Setup(x => x.ApproveGradeChange(5, ref errors));

            //// Act
            gradeChangeService.ApproveGradeChange(gc, ref errors);
            mockRepository.Verify(mock => mock.ApproveGradeChange(1, ref errors), Times.Once());

            //// Assert
            Assert.AreEqual(0, errors.Count);
        }
        public void AddGradeChange(GradeChange gradeChange, ref List<string> errors)
        {
            grade_change db_gradeChange = new grade_change();

            try
            {
                db_gradeChange.student_id = gradeChange.Student_id;
                db_gradeChange.schedule_id = gradeChange.Schedule_id;
                db_gradeChange.course_id = gradeChange.Course_id;
                db_gradeChange.approved = gradeChange.Approved;
                db_gradeChange.desired = gradeChange.Desired;
                db_gradeChange.description = gradeChange.Description;

                this.context.grade_change.Add(db_gradeChange);
                this.context.SaveChanges();
            }
            catch (Exception e)
            {
                errors.Add("Error occured in GradeChangeRepository.RequestGradeChange: " + e);
            }
        }
 protected void OnGradeChange(GradeChangeEventArg arg)
 {
     GradeChange?.Invoke(this, arg);
 }