Initial commit

This commit is contained in:
github-classroom[bot] 2024-09-12 12:42:00 +00:00 committed by GitHub
commit 612509ac25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 4614 additions and 0 deletions

3551
.editorconfig Normal file

File diff suppressed because it is too large Load diff

583
.gitignore vendored Normal file
View file

@ -0,0 +1,583 @@
# Created by https://www.toptal.com/developers/gitignore/api/csharp,visualstudio
# Edit at https://www.toptal.com/developers/gitignore?templates=csharp,visualstudio
### Csharp ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
### VisualStudio ###
# User-specific files
# User-specific files (MonoDevelop/Xamarin Studio)
# Mono auto generated files
# Build results
# Visual Studio 2015/2017 cache/options directory
# Uncomment if you have tasks that create the project's static files in wwwroot
# Visual Studio 2017 auto generated files
# MSTest test Results
# NUnit
# Build Results of an ATL Project
# Benchmark Results
# .NET Core
# ASP.NET Scaffolding
# StyleCop
# Files built by Visual Studio
# Chutzpah Test files
# Visual C++ cache files
# Visual Studio profiler
# Visual Studio Trace Files
# TFS 2012 Local Workspace
# Guidance Automation Toolkit
# ReSharper is a .NET coding add-in
# TeamCity is a build add-in
# DotCover is a Code Coverage Tool
# AxoCover is a Code Coverage Tool
# Coverlet is a free, cross platform Code Coverage Tool
# Visual Studio code coverage results
# NCrunch
# MightyMoose
# Web workbench (sass)
# Installshield output folder
# DocProject is a documentation generator add-in
# Click-Once directory
# Publish Web Output
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
# NuGet Packages
# NuGet Symbol Packages
# The packages folder can be ignored because of Package Restore
# except build/, which is used as an MSBuild target.
# Uncomment if necessary however generally it will be regenerated when needed
# NuGet v3's project.json files produces more ignorable files
# Microsoft Azure Build Output
# Microsoft Azure Emulator
# Windows Store app package directories and files
# Visual Studio cache files
# files ending in .cache can be ignored
# but keep track of directories ending in .cache
# Others
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
# RIA/Silverlight projects
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
# SQL Server files
# Business Intelligence projects
# Microsoft Fakes
# GhostDoc plugin setting file
# Node.js Tools for Visual Studio
# Visual Studio 6 build log
# Visual Studio 6 workspace options file
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
# Visual Studio 6 technical files
# Visual Studio LightSwitch build output
# Paket dependency manager
# FAKE - F# Make
# CodeRush personal settings
# Python Tools for Visual Studio (PTVS)
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
# Telerik's JustMock configuration file
# BizTalk build output
# OpenCover UI analysis results
# Azure Stream Analytics local run output
# MSBuild Binary and Structured Log
# NVidia Nsight GPU debugger configuration file
# MFractors (Xamarin productivity tool) working folder
# Local History for Visual Studio
# Visual Studio History (VSHistory) files
# BeatPulse healthcheck temp database
# Backup folder for Package Reference Convert tool in Visual Studio 2017
# Ionide (cross platform F# VS Code tools) working folder
# Fody - auto-generated XML schema
# VS Code files for those working on multiple tools
# Local History for Visual Studio Code
# Windows Installer files from build outputs
# JetBrains Rider
### VisualStudio Patch ###
# Additional files built by Visual Studio
# End of https://www.toptal.com/developers/gitignore/api/csharp,visualstudio

3
CleanSolutionDir.ps1 Normal file
View file

@ -0,0 +1,3 @@
Get-ChildItem -Path $PSScriptroot -Recurse -Force -Include '.vs', '.git', 'bin', 'obj', '.idea', '*.Dotsettings', '*.Dotsettings.user' | ForEach-Object {
Remove-Item -Recurse -Force -LiteralPath $_.FullName >$null
}

View file

View file

@ -0,0 +1 @@
Home;Guest;GoalsHome;GoalsGuest
1 Home Guest GoalsHome GoalsGuest

View file

@ -0,0 +1,4 @@
Home;Guest;GoalsHome;GoalsGuest;Diff
Belgien;Deutschland;0;1;1
Kasachstan;Türkei;0;3;3
Deutschland;Aserbaidschan;6;1;5
1 Home Guest GoalsHome GoalsGuest Diff
2 Belgien Deutschland 0 1 1
3 Kasachstan Türkei 0 3 3
4 Deutschland Aserbaidschan 6 1 5

View file

@ -0,0 +1,4 @@
Home;Guest;GoalsHome;GoalsGuest
Belgien;Deutschland;0;1
Kasachstan;Türkei;0;3
Deutschland;;6;1
1 Home Guest GoalsHome GoalsGuest
2 Belgien Deutschland 0 1
3 Kasachstan Türkei 0 3
4 Deutschland 6 1

View file

@ -0,0 +1,4 @@
Home;Guest;GoalsHome;GoalsGuest
Belgien;Deutschland;0;1
Kasachstan;Türkei;0;3
Deutschland;Aserbaidschan;6;1
1 Home Guest GoalsHome GoalsGuest
2 Belgien Deutschland 0 1
3 Kasachstan Türkei 0 3
4 Deutschland Aserbaidschan 6 1

View file

@ -0,0 +1,47 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EM-Qual\EM-Qual.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Data\empty_01.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\empty_02.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\invalid_01.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\invalid_02.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\valid.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View file

@ -0,0 +1,177 @@
using FluentAssertions;
using Xunit;
namespace EMQual.Test;
public sealed class QualDataTests
{
[Fact]
public void IsCountryMatch_None()
{
Match match = new(new TeamResult("Foo", 1), new TeamResult("Bar", 2));
QualData.IsCountryMatch(match, "Baz")
.Should().BeFalse("Country did not play in this match");
}
[Fact]
public void IsCountryMatch_Home()
{
const string Country = "Baz";
Match match = new(new TeamResult(Country, 1), new TeamResult("Bar", 2));
QualData.IsCountryMatch(match, Country)
.Should().BeTrue("Country participated in match");
}
[Fact]
public void IsCountryMatch_Guest()
{
const string Country = "Baz";
Match match = new(new TeamResult("Foo", 1), new TeamResult(Country, 2));
QualData.IsCountryMatch(match, Country)
.Should().BeTrue("Country participated in match");
}
[Fact]
public void FilterMatchesByCountry_None()
{
var matches = new Match[]
{
new(new TeamResult("Foo", 3), new TeamResult("Bar", 0)),
new(new TeamResult("Foo", 1), new TeamResult("Qux", 1))
};
QualData.FilterMatchesByCountry(matches, "Baz")
.Should().NotBeNull("array has been created")
.And.BeEmpty("no matches for the supplied country");
}
[Fact]
public void FilterMatchesByCountry_Simple()
{
var matches = new Match[]
{
new(new TeamResult("Foo", 3), new TeamResult("Bar", 0)),
new(new TeamResult("Qux", 1), new TeamResult("Foo", 1)),
new(new TeamResult("Bar", 1), new TeamResult("Qux", 2))
};
QualData.FilterMatchesByCountry(matches, "Foo")
.Should().NotBeNull("array has been created")
.And.HaveCount(2, "country participated in two matches")
.And.Contain(new[] { matches[0], matches[1] });
}
[Fact]
public void ExtractUniqueCountryNames_Simple()
{
var matches = new Match[]
{
new(new TeamResult("Foo", 3), new TeamResult("Bar", 0)),
new(new TeamResult("Qux", 1), new TeamResult("Foo", 1)),
new(new TeamResult("Bar", 1), new TeamResult("Qux", 2)),
new(new TeamResult("Baz", 3), new TeamResult("Qux", 1))
};
QualData.ExtractUniqueCountryNames(matches)
.Should().NotBeNull("array has been created")
.And.HaveCount(4, "number of different countries in all matches")
.And.Contain(new[] { "Foo", "Bar", "Qux", "Baz" }, "names of the countries");
}
[Fact]
public void IsContained_Empty()
{
QualData.IsContained("Foo", Array.Empty<string>())
.Should().BeFalse("array is empty");
}
[Fact]
public void IsContained_NotContained()
{
var possValues = new[] { "Bar", "Baz", "Qux" };
QualData.IsContained("Foo", possValues)
.Should().BeFalse("value not contained");
}
[Fact]
public void IsContained_Contained()
{
var possValues = new[] { "Bar", "Baz", "Foo", "Qux" };
QualData.IsContained("Foo", possValues)
.Should().BeTrue("value is contained");
}
[Fact]
public void IsContained_IgnoreCase()
{
var possValues = new[] { "Bar", "Baz", "Foo", "Qux" };
QualData.IsContained("fOo", possValues)
.Should().BeTrue("value is contained");
}
[Fact]
public void TryParseMatch_Simple()
{
const string Line = "Foo;Bar;2;3";
QualData.TryParseMatch(Line, out var parsedMatch)
.Should().BeTrue("valid line could be parsed");
parsedMatch.Should().NotBeNull("successful parse, instance created")
.And.BeEquivalentTo(new Match(new TeamResult("Foo", 2),
new TeamResult("Bar", 3)));
}
[Theory]
[InlineData("Foo;Bar;2;-3", "invalid goals")]
[InlineData("Foo;Bar;t;3", "invalid goals")]
[InlineData("Foo;Bar;2", "missing value")]
[InlineData("Foo;Bar;2;1;4", "superfluous value")]
[InlineData("Foo;1;Bar;2", "wrong order")]
[InlineData("Foo;;1;2", "empty name")]
[InlineData("Foo-Bar-1-2", "invalid separator")]
public void TryParseMatch_Invalid(string line, string reason)
{
QualData.TryParseMatch(line, out var parsedMatch)
.Should().BeFalse($"line could not be parsed: {reason}");
parsedMatch.Should().BeNull("parsing failed, no instance created");
}
[Fact]
public void ReadMatchesFromFile_Simple()
{
var expectedMatches = new Match[]
{
new(new TeamResult("Belgien", 0), new TeamResult("Deutschland", 1)),
new(new TeamResult("Kasachstan", 0), new TeamResult("Türkei", 3)),
new(new TeamResult("Deutschland", 6), new TeamResult("Aserbaidschan", 1))
};
var matches = QualData.ReadMatchesFromFile("Data/valid.csv");
matches.Should().NotBeNullOrEmpty("valid file containing valid matches processed")
.And.HaveCount(3, "three matches defined in the file")
.And.ContainInOrder(expectedMatches, "how the matches should have been parsed");
}
[Theory]
[InlineData("Data/none.csv", "the file does not exist, so no entries could be parsed")]
[InlineData("Data/empty_01.csv", "the file exists but is empty, so no entries could be parsed")]
[InlineData("Data/empty_02.csv", "the file exists but contains only the header, so no entries could be parsed")]
[InlineData("Data/invalid_01.csv", "the file contains unexpected information, so parsing failed")]
[InlineData("Data/invalid_02.csv", "the file contains an invalid entry, so none are returned")]
public void ReadMatchesFromFile_Invalid(string filePath, string reason)
{
QualData.ReadMatchesFromFile(filePath)
.Should().NotBeNull("an array is created and returned in any case")
.And.HaveCount(0, reason)
.And.BeSameAs(Array.Empty<Match>(), "empty array created properly");
}
}

30
EM-Qual.sln Normal file
View file

@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32126.317
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EM-Qual", "EM-Qual\EM-Qual.csproj", "{F687519F-3209-44B6-81BF-DDD2466FEEF2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EM-Qual.Test", "EM-Qual.Test\EM-Qual.Test.csproj", "{C0CE7914-5D5B-4C90-A993-A8F8CC7002E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F687519F-3209-44B6-81BF-DDD2466FEEF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F687519F-3209-44B6-81BF-DDD2466FEEF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F687519F-3209-44B6-81BF-DDD2466FEEF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F687519F-3209-44B6-81BF-DDD2466FEEF2}.Release|Any CPU.Build.0 = Release|Any CPU
{C0CE7914-5D5B-4C90-A993-A8F8CC7002E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0CE7914-5D5B-4C90-A993-A8F8CC7002E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0CE7914-5D5B-4C90-A993-A8F8CC7002E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0CE7914-5D5B-4C90-A993-A8F8CC7002E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B7BD828E-2CBE-4D53-BA50-CC9536773BE0}
EndGlobalSection
EndGlobal

24
EM-Qual/Data/matches.csv Normal file
View file

@ -0,0 +1,24 @@
Home;Guest;GoalsHome;GoalsGuest
Belgien;Deutschland;0;1
Kasachstan;Türkei;0;3
Deutschland;Aserbaidschan;6;1
Österreich;Kasachstan;2;0
Türkei;Belgien;3;2
Kasachstan;Belgien;0;2
Österreich;Aserbaidschan;3;0
Deutschland;Türkei;3;0
Aserbaidschan;Türkei;1;0
Kasachstan;Deutschland;0;3
Belgien;Österreich;4;4
Österreich;Belgien;0;2
Deutschland;Kasachstan;4;0
Türkei;Österreich;2;0
Belgien;Aserbaidschan;4;1
Kasachstan;Aserbaidschan;2;1
Österreich;Deutschland;1;2
Belgien;Türkei;1;1
Aserbaidschan;Deutschland;1;3
Aserbaidschan;Belgien;1;1
Türkei;Kasachstan;2;1
Deutschland;Österreich;6;2
Österreich;Türkei;0;0
1 Home Guest GoalsHome GoalsGuest
2 Belgien Deutschland 0 1
3 Kasachstan Türkei 0 3
4 Deutschland Aserbaidschan 6 1
5 Österreich Kasachstan 2 0
6 Türkei Belgien 3 2
7 Kasachstan Belgien 0 2
8 Österreich Aserbaidschan 3 0
9 Deutschland Türkei 3 0
10 Aserbaidschan Türkei 1 0
11 Kasachstan Deutschland 0 3
12 Belgien Österreich 4 4
13 Österreich Belgien 0 2
14 Deutschland Kasachstan 4 0
15 Türkei Österreich 2 0
16 Belgien Aserbaidschan 4 1
17 Kasachstan Aserbaidschan 2 1
18 Österreich Deutschland 1 2
19 Belgien Türkei 1 1
20 Aserbaidschan Deutschland 1 3
21 Aserbaidschan Belgien 1 1
22 Türkei Kasachstan 2 1
23 Deutschland Österreich 6 2
24 Österreich Türkei 0 0

17
EM-Qual/EM-Qual.csproj Normal file
View file

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<None Update="Data\matches.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

15
EM-Qual/Model.cs Normal file
View file

@ -0,0 +1,15 @@
namespace EMQual;
/// <summary>
/// Match result for a single team.
/// </summary>
/// <param name="TeamName">Name of the team</param>
/// <param name="Goals">Number of goals scored by this team</param>
public record TeamResult(string TeamName, int Goals);
/// <summary>
/// Match results for one game.
/// </summary>
/// <param name="HomeTeam">Match result for the home team</param>
/// <param name="GuestTeam">Match result for the guest team</param>
public record Match(TeamResult HomeTeam, TeamResult GuestTeam);

7
EM-Qual/Program.cs Normal file
View file

@ -0,0 +1,7 @@
using System.Text;
using EMQual;
Console.OutputEncoding = Encoding.UTF8;
Console.WriteLine($"*** EM Qualification Results ***{Environment.NewLine}");
QualData.Run();

117
EM-Qual/QualData.cs Normal file
View file

@ -0,0 +1,117 @@
namespace EMQual;
public static class QualData
{
/// <summary>
/// Executes the <see cref="QualData"/> program.
/// </summary>
public static void Run()
{
var matches = ReadMatchesFromFile("Data/matches.csv");
PrintMatches(matches);
Console.WriteLine();
var countryNames = ExtractUniqueCountryNames(matches);
var selCountry = AskForCountry(countryNames);
var countryMatches = FilterMatchesByCountry(matches, selCountry);
PrintMatches(countryMatches);
}
/// <summary>
/// Reads match information from a CSV file at the provided location.
/// If the file does not exist or does not contain relevant or some
/// corrupted data an empty array is returned.
/// </summary>
/// <param name="filePath">The relative path to the CSV file</param>
/// <returns>An array containing parsed match data records</returns>
public static Match[] ReadMatchesFromFile(string filePath)
{
// TODO
return [];
}
/// <summary>
/// Attempts to parse a line with semicolon separated data for a match.
/// </summary>
/// <param name="line">Line to parse</param>
/// <param name="match">Parsed match object; null if parsing fails</param>
/// <returns>True if the line could be parsed successfully; false otherwise</returns>
public static bool TryParseMatch(string line, out Match? match)
{
// TODO
match = null;
return false;
}
/// <summary>
/// Determines if the supplied string is contained in the provided array of strings.
/// Case is ignored.
/// </summary>
/// <param name="value">Value to check for</param>
/// <param name="possibleValues">Array of values to check in</param>
/// <returns>True if the value is found; false otherwise</returns>
public static bool IsContained(string value, string[] possibleValues)
{
// TODO
return false;
}
/// <summary>
/// Returns an array containing the names of all countries which have participated
/// in at least one match exactly one time.
/// </summary>
/// <param name="matches">Array of all matches played</param>
/// <returns>An array of unique country names</returns>
public static string[] ExtractUniqueCountryNames(Match[] matches)
{
// TODO
return [];
}
/// <summary>
/// Returns a new array of matches, based on the supplied full collection, but
/// with filtered to only contain matches the provided country participated in.
/// </summary>
/// <param name="allMatches">Array of all matches played</param>
/// <param name="countryName">Name of the country to filter for</param>
/// <returns>Array of matches in which the supplied country participated</returns>
public static Match[] FilterMatchesByCountry(Match[] allMatches, string countryName)
{
// TODO
return [];
}
/// <summary>
/// Determines if the supplied match is one the provided country participated in.
/// </summary>
/// <param name="match">Match to check</param>
/// <param name="countryName">Country for which to check</param>
/// <returns>True if the country participated in the match; false otherwise</returns>
public static bool IsCountryMatch(Match match, string countryName)
{
// TODO
return false;
}
/// <summary>
/// Prints the matches to the terminal.
/// </summary>
/// <param name="matches">Array of matches to print</param>
private static void PrintMatches(Match[] matches)
{
// TODO
}
/// <summary>
/// Asks the user to enter a country to filter for.
/// The user can only enter one of the existing countries. Case is not relevant.
/// If the user enters something invalid the input request is retried until the user gets it right.
/// </summary>
/// <param name="possibleCountries">Array containing the names of possible countries to pick from</param>
/// <returns>The name of the country the user selected</returns>
private static string AskForCountry(string[] possibleCountries)
{
// TODO
return string.Empty;
}
}

30
readme.adoc Normal file
View file

@ -0,0 +1,30 @@
:sectnums:
:nofooter:
:toc: left
:icons: font
= Exercise Rep.01 -- EM Qualification Data
You have been provided with a file `matches.csv` which contains information about matches played during the qualification for a soccer EM.
== Displaying Information
This data has to be read and displayed in a specific format to the user.
* Make sure to read & parse information from the CSV file properly
* Handle invalid/corrupted data as well as missing or invalid files
* Ensure to format the information as shown in the sample below
== User Input & Processing
The user can enter the name of one of the countries.
Then all matches this country participated in are displayed (= filtered result set).
* The user can only enter one of the existing countries
* If the user input is invalid it is retried until a valid entry is made
TIP: You might find `StringComparison.InvariantCultureIgnoreCase` useful.
== Sample Run
video::sample.mp4[width=800]

BIN
sample.mp4 Normal file

Binary file not shown.