public void FiltrationTest1() { LINQMethods LINQMethods = new LINQMethods(); // исходные данные Student[] expected = new Student[] { new Student(5, "Авдеев", "Никита", "Владимирович", Convert.ToDateTime("09.07.1997"), "525б", 68, 800), new Student(1, "Aндриенко", "Александр", "Игоревич", Convert.ToDateTime("01.06.1999"), "525", 95.8, 1300) }; 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, 800), new Student(3, "Герлиц", "Роман", "Сергеевич", Convert.ToDateTime("02.02.1998"), "525а", 77, 1300), new Student(1, "Aндриенко", "Александр", "Игоревич", Convert.ToDateTime("01.06.1999"), "525", 95.8, 1300) }; // получение значения с помощью тестируемого метода var actual = LINQMethods.Filtration(2, "А", source); // сравнение ожидаемого результата с полученным int i = 0; foreach (Student s in actual) { Assert.AreEqual(s.id, expected[i].id); 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; } }