public void GetYoungestStudent() { //var student = PracticeData/*FILL IN LINQ EXPRESSION*/; var student = PracticeData.SelectMany(c => c.Students).OrderByDescending(s => s.Birthday).First(); Assert.AreEqual(student, CohortBuilder.Student3); }
public void GetAllStudents() { //var expected = PracticeData/*FILL IN LINQ EXPRESSION*/.ToList(); var expected = PracticeData.SelectMany(c => c.Students).ToList(); CollectionAssert.AreEqual(expected, new List <Student> { CohortBuilder.Student1, CohortBuilder.Student2, CohortBuilder.Student3, CohortBuilder.Student4, CohortBuilder.Student5, CohortBuilder.Student6, CohortBuilder.Student7, CohortBuilder.Student8, CohortBuilder.Student9, CohortBuilder.Student10, CohortBuilder.Student11, CohortBuilder.Student12, CohortBuilder.Student13, CohortBuilder.Student14, CohortBuilder.Student15, CohortBuilder.Student16, CohortBuilder.Student17, CohortBuilder.Student18, CohortBuilder.Student19, CohortBuilder.Student20 }); }
public void GetAllInactiveStudentsByLastName() { var ActualStudents = PracticeData.SelectMany(cohort => cohort.Students).Where(student => student.Active == false).OrderBy(student => student.LastName).ToList(); CollectionAssert.AreEqual(ActualStudents, new List <Student> { CohortBuilder.Student2, CohortBuilder.Student11, CohortBuilder.Student12, CohortBuilder.Student17 }); }
public void GetAllStudents() { var expected = PracticeData.SelectMany(c => { return(c.Students); }).ToList(); CollectionAssert.AreEqual(expected, new List <Student> { CohortBuilder.Student1, CohortBuilder.Student2, CohortBuilder.Student3, CohortBuilder.Student4, CohortBuilder.Student5, CohortBuilder.Student6, CohortBuilder.Student7, CohortBuilder.Student8, CohortBuilder.Student9, CohortBuilder.Student10, CohortBuilder.Student11, CohortBuilder.Student12, CohortBuilder.Student13, CohortBuilder.Student14, CohortBuilder.Student15, CohortBuilder.Student16, CohortBuilder.Student17, CohortBuilder.Student18, CohortBuilder.Student19, CohortBuilder.Student20 }); }
public void GetAllInactiveStudentsByLastName() { var ActualStudents = PracticeData.SelectMany(c => { return(c.Students); }).Where(s => { return(!s.Active); }).OrderBy(s => { return(s.LastName); }).ToList(); CollectionAssert.AreEqual(ActualStudents, new List <Student> { CohortBuilder.Student2, CohortBuilder.Student11, CohortBuilder.Student12, CohortBuilder.Student17 }); }
public void GetAllInactiveStudentsByLastName() { var ActualStudents = PracticeData.SelectMany(cohort => cohort.Students).Where(student => !student.Active) /*FILL IN LINQ EXPRESSION*/.ToList(); CollectionAssert.AreEqual(ActualStudents, new List <Student> { CohortBuilder.Student2, CohortBuilder.Student11, CohortBuilder.Student12, CohortBuilder.Student17 }); }
public void GetOldestStudent() { //var allStudents = PracticeData.SelectMany(c => c.Students).ToList(); //var allStudents = PracticeData.SelectMany(c => c.Students); //var studentBdays = allStudents.OrderBy(s => s.Birthday); //var student = PracticeData/*FILL IN LINQ EXPRESSION*/; var student = PracticeData.SelectMany(c => c.Students).OrderBy(s => s.Birthday).First(); Assert.AreEqual(student, CohortBuilder.Student18); }
public void GetOldestStudent() { // this does not work // var student = PracticeData.SelectMany(cohort => cohort.Students).Min(eachStudent => eachStudent.Birthday)/*FILL IN LINQ EXPRESSION*/; // this works //var student = (from eachStudent in PracticeData.SelectMany(cohort => cohort.Students) // orderby eachStudent.Birthday ascending // select eachStudent).First(); var student = PracticeData.SelectMany(cohort => cohort.Students).OrderBy(eachStudent => eachStudent.Birthday).First(); Assert.AreEqual(student, CohortBuilder.Student18); }
public void GetAllInactiveStudentsByLastName() { //var alphaStudents = PracticeData.SelectMany(c => c.Students).OrderBy(s => s.LastName); //var ActualStudents = PracticeData/*FILL IN LINQ EXPRESSION*/.ToList(); var ActualStudents = PracticeData.SelectMany(c => c.Students).OrderBy(s => s.LastName).Where(s => s.Active == false).ToList(); CollectionAssert.AreEqual(ActualStudents, new List <Student> { CohortBuilder.Student2, CohortBuilder.Student11, CohortBuilder.Student12, CohortBuilder.Student17 }); }
public void GetYoungestStudent() { var student = PracticeData.SelectMany(cohort => cohort.Students).OrderByDescending(students => students.Birthday).First(); Assert.AreEqual(student, CohortBuilder.Student3); }
public void GetOldestStudent() { var student = PracticeData.SelectMany(cohort => cohort.Students).OrderBy(s => s.Birthday).First(); Assert.AreEqual(student, CohortBuilder.Student18); }
public void GetYoungestStudent() { var student = PracticeData.SelectMany(c => c.Students).OrderBy(s => s.Birthday).Last(); Assert.AreEqual(student, CohortBuilder.Student3); }
public void GetYoungestStudent() { var student = PracticeData.SelectMany(c => c.Students).Single(s => { return(s.Birthday == PracticeData.SelectMany(c => { return c.Students; }).Max(st => { return st.Birthday; })); }); Assert.AreEqual(student, CohortBuilder.Student3); }
public void GetYoungestStudent() { var student = PracticeData.SelectMany(cohort => cohort.Students).OrderByDescending(pupil => pupil.Birthday).ToList()[0]; /*FILL IN LINQ EXPRESSION*/ Assert.AreEqual(student, CohortBuilder.Student3); }
public void GetYoungestStudent() { var student = PracticeData.SelectMany(cohort => cohort.Students).OrderByDescending(eachStudent => eachStudent.Birthday).First() /*FILL IN LINQ EXPRESSION*/; Assert.AreEqual(student, CohortBuilder.Student3); }