From d1989c777c6ec0790a2731d9e9c790f956e76e4b Mon Sep 17 00:00:00 2001 From: flovnes Date: Tue, 30 Apr 2024 17:22:08 +0300 Subject: [PATCH 1/3] tests --- src/data_new.txt | 20 -------------------- tests/tests.cs | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 27 deletions(-) delete mode 100644 src/data_new.txt diff --git a/src/data_new.txt b/src/data_new.txt deleted file mode 100644 index a09fcb9..0000000 --- a/src/data_new.txt +++ /dev/null @@ -1,20 +0,0 @@ -surname2 firstname3 patronymic3 Ж 06.12.1995 - 3 5 4756 -surname4 firstname2 patronymic3 Ж 10.09.1995 2 - 1 3291 -surname2 firstname4 patronymic4 Ж 07.05.2004 2 3 3 2103 -surname1 firstname1 patronymic2 Ж 05.05.1998 1 - - 2766 -surname3 firstname2 patronymic3 Ч 03.02.2001 - 3 1 2260 -surname1 firstname1 patronymic2 Ж 12.04.2002 2 3 - 4495 -surname4 firstname1 patronymic3 Ж 04.09.2005 3 2 4 4183 -surname3 firstname1 patronymic2 Ж 08.07.2004 5 5 2 4345 -surname2 firstname2 patronymic1 Ч 22.01.1999 2 1 5 3870 -surname1 firstname1 patronymic1 Ч 04.05.2005 4 3 4 3302 -surname2 firstname3 patronymic3 Ж 16.12.1995 1 3 5 2801 -surname3 firstname2 patronymic3 Ж 24.08.1999 4 5 3 4139 -surname4 firstname3 patronymic4 Ч 26.07.1998 2 3 4 2548 -surname1 firstname3 patronymic1 Ч 23.06.1998 1 4 - 1092 -surname1 firstname3 patronymic2 Ж 15.10.2000 5 3 3 1577 -surname2 firstname2 patronymic2 Ч 08.12.2004 3 5 2 4394 -surname4 firstname1 patronymic3 Ч 05.08.1998 2 - 2 1404 -surname3 firstname4 patronymic3 Ж 15.12.1998 1 3 4 1133 -surname3 firstname3 patronymic2 Ч 06.09.2000 2 3 3 1118 -surname4 firstname2 patronymic3 Ж 22.12.2003 3 4 3 2677 diff --git a/tests/tests.cs b/tests/tests.cs index 363e5d9..ceaea2b 100644 --- a/tests/tests.cs +++ b/tests/tests.cs @@ -16,7 +16,7 @@ public static void Student_Constructor_ReturnStudentList() } [Fact] - public static void TestVar10() + public static void Student_Var10_ReturnStudents() { List students = []; students.Add(new("Андрущенко Вадим Миколайович M 23.06.2004 2 1 - 1285")); @@ -24,21 +24,46 @@ public static void TestVar10() students.Add(new("Кірпіч Влад Шварцович Ч 12.06.1998 4 4 5 3538")); students.Add(new("Муха Саня Респектович F 12.11.1999 3 5 4 3392")); - int count = 0; + int counter = 0; foreach (Student student in students) { if (Program.IsTalentedPhysician(student)) - count++; + counter++; } - Assert.Equal(2, count); + Assert.Equal(2, counter); + } - double[] expectedAverages = { 1.7, 4.0, 4.3, 4.0 }; + [Fact] + public static void Student_EvalAverage_ReturnDouble() + { int counter = 0; - foreach (var student in students) + List students = []; + students.Add(new("Прізвище1 Ім'я1 По-батькові1 M 02.02.2000 - 4 5 1234")); + students.Add(new("surname FIRST_NAME 🔥 F 02.02.2000 3 1 3 1234")); + students.Add(new("1 2 3 4 5 - 5 - 6666")); + double[] expectedAverages = [3.7, 2.3, 3.0]; + foreach (var (student, average) in students.Zip(expectedAverages)) { - Assert.Equal(Program.EvalAverage(student), expectedAverages[counter]); + Assert.Equal(average, Program.EvalAverage(student)); counter++; } } + + [Fact] + public static void Student_FilterSummer_ReturnStudents() + { + List students = []; + students.Add(new("Прізвище1 Ім'я1 По-батькові1 M 02.02.4000 3 5 2 1234")); + students.Add(new("surname FIRST_NAME 🔥 F 02.06.3220 3 3 3 1234")); + students.Add(new("1 2 3 4 29.08.2002 - 5 - 6666")); + + int count = 0; + foreach (Student student in students) + { + if (Program.IsBornInSummer(student)) + count++; + } + Assert.Equal(2, count); + } } } From 6b6706655ad0fecd99de942e411a111705966012 Mon Sep 17 00:00:00 2001 From: flovnes Date: Tue, 30 Apr 2024 17:26:19 +0300 Subject: [PATCH 2/3] i forgor to sqve --- src/methods.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/methods.cs b/src/methods.cs index 27b8704..3f2e57d 100644 --- a/src/methods.cs +++ b/src/methods.cs @@ -19,7 +19,7 @@ public static void Var10(List students) public static void Var24(List students) { Console.WriteLine("\nСписок студентів, які народились влітку:"); - var summer_kids = Filter(students, IsSummer); + var summer_kids = Filter(students, IsBornInSummer); foreach (var dude in summer_kids) Console.WriteLine($"\r{dude.surName} {dude.firstName} {EvalAverage(dude):0.0}"); @@ -58,7 +58,7 @@ public static IEnumerable Filter(List students, Func= 6 && month <= 8; From 93ad1d94005870d424f458014f4d5273a08dc1cb Mon Sep 17 00:00:00 2001 From: flovnes Date: Tue, 30 Apr 2024 19:09:48 +0300 Subject: [PATCH 3/3] changes --- tests/tests.cs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/tests.cs b/tests/tests.cs index ceaea2b..a615dc6 100644 --- a/tests/tests.cs +++ b/tests/tests.cs @@ -16,7 +16,23 @@ public static void Student_Constructor_ReturnStudentList() } [Fact] - public static void Student_Var10_ReturnStudents() + public static void Student_EvalAverage_ReturnDouble() + { + int counter = 0; + List students = []; + students.Add(new("Прізвище1 Ім'я1 По-батькові1 M 02.02.2000 - 4 5 1234")); + students.Add(new("surname FIRST_NAME 🔥 F 02.02.2000 3 1 3 1234")); + students.Add(new("1 2 3 4 5 - 5 - 6666")); + double[] expectedAverages = [3.7, 2.3, 3.0]; + foreach (var (student, average) in students.Zip(expectedAverages)) + { + Assert.Equal(average, Program.EvalAverage(student)); + counter++; + } + } + + [Fact] + public static void Student_FilterPhysicians_ReturnStudents() { List students = []; students.Add(new("Андрущенко Вадим Миколайович M 23.06.2004 2 1 - 1285")); @@ -32,22 +48,6 @@ public static void Student_Var10_ReturnStudents() } Assert.Equal(2, counter); } - - [Fact] - public static void Student_EvalAverage_ReturnDouble() - { - int counter = 0; - List students = []; - students.Add(new("Прізвище1 Ім'я1 По-батькові1 M 02.02.2000 - 4 5 1234")); - students.Add(new("surname FIRST_NAME 🔥 F 02.02.2000 3 1 3 1234")); - students.Add(new("1 2 3 4 5 - 5 - 6666")); - double[] expectedAverages = [3.7, 2.3, 3.0]; - foreach (var (student, average) in students.Zip(expectedAverages)) - { - Assert.Equal(average, Program.EvalAverage(student)); - counter++; - } - } [Fact] public static void Student_FilterSummer_ReturnStudents() @@ -57,13 +57,13 @@ public static void Student_FilterSummer_ReturnStudents() students.Add(new("surname FIRST_NAME 🔥 F 02.06.3220 3 3 3 1234")); students.Add(new("1 2 3 4 29.08.2002 - 5 - 6666")); - int count = 0; + int counter = 0; foreach (Student student in students) { if (Program.IsBornInSummer(student)) - count++; + counter++; } - Assert.Equal(2, count); + Assert.Equal(2, counter); } } }