public void GetAllTutors_ShouldReturnAllTutors() { //Arrange const int expectTutorCount = 3; var tutorDal1 = new TutorStudentDal() { Id = 1, Number = 112345, LastName = "Zozo1" }; var tutorDal2 = new TutorStudentDal() { Id = 2, Number = 212345, LastName = "Zozo2" }; var tutorDal3 = new TutorStudentDal() { Id = 3, Number = 312345, LastName = "Zozo3" }; var tutors = new List <TutorStudentDal> { tutorDal1, tutorDal2, tutorDal3 }; _tutorRepository.GetAll().Returns(tutors.AsQueryable()); //Act var tutorStudentList = _tutoService.GetAllTutors(); //Assert Assert.AreEqual(expectTutorCount, tutorStudentList.Count()); //Avec Fluent Assertions tutorStudentList.Count().ShouldBeEquivalentTo(expectTutorCount); }
public static TutorStudent Map(TutorStudentDal entityStudent) { return(new TutorStudent() { Id = entityStudent.Id, Number = entityStudent.Number, LastName = entityStudent.LastName }); }
private static void Main(/*string[] args*/) { Console.WriteLine("Hello World"); var dbContext = new EfTutoringDbContext(); var tutorRepo = new EfEntityRepository <TutorStudentDal>(dbContext); tutorRepo.DeleteAll(); var tutor1 = new TutorStudentDal() { Number = 1234, LastName = "Bilodeau" }; tutorRepo.Add(tutor1); var tutor2 = new TutorStudentDal() { Number = 12345, LastName = "Bob" }; tutorRepo.Add(tutor2); var tutorList = tutorRepo.GetAll(); Console.WriteLine("Liste des tuteurs"); foreach (var tutor in tutorList) { Console.WriteLine(tutor.Number + " - " + tutor.LastName); } Console.ReadKey(); //var tutorsList = tutorRepo.GetAll(); //var tutorsGagnon = tutorsList.Where(t => t.LastName == "Gagnon"); var tutor3 = new TutorStudentDal() { Number = 123456, LastName = "Roger" }; tutorRepo.Add(tutor3); /*var sessionRepo = new EfEntityRepository<TutoringSessionDal>(dbContext); * var tutor3FromBd = tutorRepo.GetById(tutor3.Id); * var session1 = new TutoringSessionDal() * { * DateTimeSession = new DateTime(2016, 03, 16), * LengthSession = 1, * TutorStudentDal = tutor3FromBd * }; * sessionRepo.Add(session1);*/ var appContext = new EfTutoringDbContext(); var sessionRepo = new EfEntityRepository <TutoringSessionDal>(appContext); sessionRepo.Add(new TutoringSessionDal() { DateTimeSession = new DateTime(2016, 04, 25, 13, 00, 00), LengthSession = 1, TutorStudentDal = tutorRepo.GetAll().FirstOrDefault(t => t.Number == 99999) }); }