public void ServiceRepository_WithMock_PromoteAllClasses_IncrementsYears()
        {
            var student = new Student { YearsCompleted = 2, IsGraduated = false };
            repositoryWithMock.Setup(r => r.GetAllStudents()).Returns(Enumerable.Repeat(student, 1));

            serviceWithMock.PromoteAllClasses();

            Assert.AreEqual(3, student.YearsCompleted);
        }
        public void ServiceRepository_WithMock_PromoteAllClasses_GraduatesStudents()
        {
            var eligibleStudent = new Student { YearsCompleted = 3, IsGraduated = false };
            var ineligibleStudent = new Student { YearsCompleted = 2, IsGraduated = false };
            repositoryWithMock.Setup(r => r.GetAllStudents()).Returns(new List<Student>() { eligibleStudent, ineligibleStudent });

            serviceWithMock.PromoteAllClasses();

            Assert.True(eligibleStudent.IsGraduated);
            Assert.False(ineligibleStudent.IsGraduated);
        }
 public void Update(Student student)
 {
     var existingStudent = this.context.Students.Find(student.Id);
     if (existingStudent == null)
     {
         Add(student);
     }
     else
     {
         existingStudent.Name = student.Name;
         existingStudent.IsGraduated = student.IsGraduated;
         existingStudent.YearsCompleted = student.YearsCompleted;
         this.context.SaveChanges();
     }
 }
 public void Add(Student student)
 {
     this.context.Students.Add(student);
     this.context.SaveChanges();
 }