private static void Ctor_ShouldWork() { var lvCombination = new LvCombination(null); Assert.Null(lvCombination.Combination); var combination = new List <List <Student> >() { new List <Student>() { new Student(0) } }; lvCombination = new LvCombination(combination); Assert.Equal(combination, lvCombination.Combination); }
private static void CompareTo_ShouldWork(List <List <int> > r1, List <List <int> > r2, bool expected) { //Populating student list with students var students = new List <Student>(); foreach (var group in r1.Concat(r2)) { foreach (int index in group) { if (students.All(s => s.Id != index)) { students.Add(new Student(index)); } } } //Converting records from int lists to student lists Func <List <List <int> >, List <List <Student> > > numberRecordToStudentRecord = record => record.Select(g => g.Select(n => students[students.IndexOf(students.First(s => s.Id == n))]).ToList()).ToList(); var record1 = new LvCombination(numberRecordToStudentRecord(r1)); var record2 = new LvCombination(numberRecordToStudentRecord(r2)); for (int i = 0; i < 2; i++) { foreach (var group in (i == 0) ? r1 : r2) { var studentGroup = new List <Student>(); foreach (int index in group) { studentGroup.Add(students.First(s => s.Id == index)); } if (i == 0) { record1.Combination.Add(studentGroup); } else { record2.Combination.Add(studentGroup); } } } //Checking if records are the same bool actual = record1.CompareTo(record2); Assert.Equal(expected, actual); }