public void FindLecturersById_ValidCall() { Mock <ILecturerRepository> mockGradeRepository = MockLecturerRepository; mockGradeRepository.Setup(mr => mr.FindByID(It.IsAny <int>())) .Returns((int s) => GetSampleLecturers().Where(x => x.Id == s).FirstOrDefault()); _mockLecturerRepository = mockGradeRepository.Object; int checkingId = 1; LecturerModel expected = _mockLecturerRepository.FindByID(checkingId); var t = GetSampleLecturers().Where(x => x.Id == checkingId); Assert.True(expected != null); // Test if null Assert.That(expected.Le_Last_Name, Is.EqualTo(GetSampleLecturers().FirstOrDefault(x => x.Id == checkingId).Le_Last_Name)); }
public void SendMessage(StudentEventArgs args) { var lections = _studentGrades.FindStudentGrades(); string st = _students.FindByID(args.grade.StudentId).St_Last_Name; string lt = _lecturer.FindByID(_lection.FindByID(args.grade.LectionId).LecturersId).Le_Last_Name; var notifyThreeLections = lections.Where(grades => grades.Key == st) .SelectMany(n => n, (n, k) => k.Grade).Reverse().Take(3).ToList(); var notifyAverageGrade = lections.Where(grades => grades.Key == st) .SelectMany(n => n, (n, k) => k.Grade).Average(); if (notifyThreeLections.TrueForAll(p => p.Equals(0))) { Log.MakeLog(LoggerOperations.Error, "NotImplementedException"); throw new NotImplementedException(); //Send mail! } if (notifyAverageGrade < 4) { Log.MakeLog(LoggerOperations.Error, "NotImplementedException"); //Send SMS to lt! } }
public IPerson FindLecturerById(int lecturerId) { return(_lecturerRepository.FindByID(lecturerId)); }