public void GroupingTest1() { LINQMethods LINQMethods = new LINQMethods(); // исходные данные Student[] expected = new Student[] { new Student(1, "Александр", "Aндриенко", "Игоревич", Convert.ToDateTime("01.06.1999"), "525", 95.8, 1300), new Student(2, "Иван", "Великий", "Иванович", Convert.ToDateTime("09.08.1999"), "525", 81.6, 1300), new Student(3, "Роман", "Герлиц", "Сергеевич", Convert.ToDateTime("02.02.1998"), "525а", 77, 1300), new Student(4, "Сергей", "Малый", "Романович", Convert.ToDateTime("01.01.1999"), "525б", 92, 900), new Student(5, "Никита", "Брихунцов", "Владимирович", Convert.ToDateTime("09.07.1997"), "525б", 68, 800) }; Student[] source = new Student[] { new Student(4, "Сергей", "Малый", "Романович", Convert.ToDateTime("01.01.1999"), "525б", 92, 1300), new Student(2, "Иван", "Великий", "Иванович", Convert.ToDateTime("09.08.1999"), "525", 81.6, 1300), new Student(5, "Никита", "Брихунцов", "Владимирович", Convert.ToDateTime("09.07.1997"), "525б", 68, 1300), new Student(3, "Роман", "Герлиц", "Сергеевич", Convert.ToDateTime("02.02.1998"), "525а", 77, 900), new Student(1, "Александр", "Aндриенко", "Игоревич", Convert.ToDateTime("01.06.1999"), "525", 95.8, 800) }; // получение значения с помощью тестируемого метода var actual = LINQMethods.Grouping(2, source); // сравнение ожидаемого результата с полученным int i = 0; foreach (var g in actual) { foreach (var s in g) { Assert.AreEqual(s.scholarship, expected[i].scholarship); i++; } } }
private void ResultsForm_Shown(object sender, EventArgs e) { LINQMethods = new LINQMethods(); int i = 0; switch (oper) { case 0: var results1 = LINQMethods.Sort(kind / 2, Convert.ToBoolean(kind % 2), data); foreach (Student s in results1) { if (s == null) { return; } DGV.RowCount++; DGV["id", i].Value = s.id; DGV["first_name", i].Value = s.first_name; DGV["second_name", i].Value = s.second_name; DGV["patronymic", i].Value = s.patronymic; DGV["group", i].Value = s.group; DGV["scholarship", i].Value = s.scholarship; DGV["average_point", i].Value = s.average_point; DGV["DOB", i].Value = s.DOB.Date; i++; } break; case 1: var results2 = LINQMethods.Filtration(kind, param, data); foreach (Student s in results2) { DGV.RowCount++; DGV["id", i].Value = s.id; DGV["first_name", i].Value = s.first_name; DGV["second_name", i].Value = s.second_name; DGV["patronymic", i].Value = s.patronymic; DGV["group", i].Value = s.group; DGV["scholarship", i].Value = s.scholarship; DGV["average_point", i].Value = s.average_point; DGV["DOB", i].Value = s.DOB.Date; i++; } break; case 2: var results3 = LINQMethods.Grouping(kind, data); foreach (var g in results3) { foreach (var s in g) { DGV.RowCount++; DGV["id", i].Value = s.id; DGV["first_name", i].Value = s.first_name; DGV["second_name", i].Value = s.second_name; DGV["patronymic", i].Value = s.patronymic; DGV["group", i].Value = s.group; DGV["scholarship", i].Value = s.scholarship; DGV["average_point", i].Value = s.average_point; DGV["DOB", i].Value = s.DOB.Date; i++; } } break; } }