public void CalculateGpaWithEnrollmentTest() { //// Arrange var errors = new List <string>(); var mockRepository = new Mock <IForeignStudentRepository>(); var foreignStudentService = new ForeignStudentService(mockRepository.Object); var enrollments = new List <Enrollment>(); enrollments.Add(new Enrollment { Grade = "A", GradeValue = 4.3f, ScheduleId = 1, StudentId = "testId" }); enrollments.Add(new Enrollment { Grade = "B", GradeValue = 3.3f, ScheduleId = 2, StudentId = "testId" }); enrollments.Add(new Enrollment { Grade = "C+", GradeValue = 2.7f, ScheduleId = 3, StudentId = "testId" }); mockRepository.Setup(x => x.GetEnrollments("testId")).Returns(enrollments); //// Act var gap = foreignStudentService.CalculateGpa("testId", enrollments, ref errors); //// Assert Assert.AreEqual(0, errors.Count); Assert.AreEqual(true, gap > 3.2f && gap < 3.5f); }
public ForeignStudent GetForeignStudent(string id) { var errors = new List <string>(); var repository = new ForeignStudentRepository(); var service = new ForeignStudentService(repository); return(service.GetForeignStudent(id, ref errors)); }
public List <ForeignStudent> GetForeignStudentList() { var errors = new List <string>(); var repository = new ForeignStudentRepository(); var service = new ForeignStudentService(repository); return(service.GetForeignStudentList(ref errors)); }
public void ForeignStudentErrorTest() { //// Arranage var errors = new List <string>(); var mockRepository = new Mock <IForeignStudentRepository>(); var foreignStudentService = new ForeignStudentService(mockRepository.Object); //// Act foreignStudentService.GetForeignStudent(null, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public void CalculateGpaErrorTest() { //// Arrange var errors = new List <string>(); var mockRepository = new Mock <IForeignStudentRepository>(); var foreignStudentService = new ForeignStudentService(mockRepository.Object); //// Act foreignStudentService.CalculateGpa(string.Empty, null, ref errors); //// Assert Assert.AreEqual(2, errors.Count); }
public string InsertForeignStudent(ForeignStudent foreignStudent) { var errors = new List <string>(); var repository = new ForeignStudentRepository(); var service = new ForeignStudentService(repository); service.InsertForeignStudent(foreignStudent, ref errors); if (errors.Count == 0) { return("ok"); } return("error"); }
public string DeleteForeignStudent(string id) { var errors = new List <string>(); var repository = new ForeignStudentRepository(); var service = new ForeignStudentService(repository); service.DeleteForeignStudent(id, ref errors); if (errors.Count == 0) { return("ok"); } return("error"); }
public void InsertForeignStudentErrorTest2() { //// Arranage var errors = new List <string>(); var mockRepository = new Mock <IForeignStudentRepository>(); var foreignStudentService = new ForeignStudentService(mockRepository.Object); var foreignStudent = new ForeignStudent { Sid = string.Empty }; //// Act foreignStudentService.InsertForeignStudent(foreignStudent, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public void CalculateGpaNoEnrollmentTest() { //// Arrange var errors = new List <string>(); var mockRepository = new Mock <IForeignStudentRepository>(); var foreignStudentService = new ForeignStudentService(mockRepository.Object); mockRepository.Setup(x => x.GetEnrollments("testId")).Returns(new List <Enrollment>()); //// Act var enrollments = foreignStudentService.GetEnrollments("testId", ref errors); var gap = foreignStudentService.CalculateGpa("testId", enrollments, ref errors); //// Assert Assert.AreEqual(0, errors.Count); Assert.AreEqual(0.0f, gap); }