Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests #10

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/data_new.txt

This file was deleted.

4 changes: 2 additions & 2 deletions src/methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void Var10(List<Student> students)
public static void Var24(List<Student> 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}");
Expand Down Expand Up @@ -58,7 +58,7 @@ public static IEnumerable<Student> Filter(List<Student> students, Func<Student,
return students.Where(Condition);
}

public static bool IsSummer(Student student)
public static bool IsBornInSummer(Student student)
{
int month = int.Parse(student.dateOfBirth[3..5]);
return month >= 6 && month <= 8;
Expand Down
43 changes: 34 additions & 9 deletions tests/tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,54 @@ public static void Student_Constructor_ReturnStudentList()
}

[Fact]
public static void TestVar10()
public static void Student_EvalAverage_ReturnDouble()
{
int counter = 0;
List<Student> 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<Student> students = [];
students.Add(new("Андрущенко Вадим Миколайович M 23.06.2004 2 1 - 1285"));
students.Add(new("Стакан Єгор Олександрович Ч 04.01.2006 4 5 3 4319"));
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);

double[] expectedAverages = { 1.7, 4.0, 4.3, 4.0 };
Assert.Equal(2, counter);
}

[Fact]
public static void Student_FilterSummer_ReturnStudents()
{
List<Student> 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 counter = 0;
foreach (var student in students)
foreach (Student student in students)
{
Assert.Equal(Program.EvalAverage(student), expectedAverages[counter]);
counter++;
if (Program.IsBornInSummer(student))
counter++;
}
Assert.Equal(2, counter);
}
}
}