From f8eec6b0c66ea90e63ded20bf4bc1d418ae2a8d1 Mon Sep 17 00:00:00 2001 From: "Leana.besson" Date: Sat, 10 Jun 2023 09:00:25 +0200 Subject: [PATCH] Ajout du test de constructeur race --- Sources/Model/Race.cs | 5 +++-- Sources/Tests/Tests.csproj | 29 +++++++++++++++++++++++++++++ Sources/Tests/Tests_race.cs | 30 ++++++++++++++++++++++++++++++ Sources/Tests/Usings.cs | 1 + Sources/Wikipet's.sln | 24 +++++++++++++++++++++++- 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 Sources/Tests/Tests.csproj create mode 100644 Sources/Tests/Tests_race.cs create mode 100644 Sources/Tests/Usings.cs diff --git a/Sources/Model/Race.cs b/Sources/Model/Race.cs index 3e6134e..13d1428 100644 --- a/Sources/Model/Race.cs +++ b/Sources/Model/Race.cs @@ -53,10 +53,10 @@ namespace Model public string? Image { get; set; } /*! - * \fn Race(string nom = "Inconnu", string nomScientifique = "Inconnu", string esperanceVie = "Inconnue", string poidsMoyen = "Inconnu", string tailleMoyenne = "Inconnu", string comportement = "Auncune information", string sante = "Aucune information", string education = "Auncune information", string entretien = "Aucune information", string cout = "Auncune information", string conseil = "Aucun conseil") + * \fn Race(string nom, string nomScientifique, string esperanceVie, string poidsMoyen, string tailleMoyenne, string comportement, string sante, string education, string entretien, string cout, string conseil, string? image = null) * \brief Race class constructor */ - public Race(string nom = "Inconnu", string nomScientifique = "Inconnu", string esperanceVie = "Inconnue", string poidsMoyen = "Inconnu", string tailleMoyenne = "Inconnu", string comportement = "Auncune information", string sante = "Aucune information", string education = "Auncune information", string entretien = "Aucune information", string cout = "Auncune information", string conseil = "Aucun conseil") + public Race(string nom, string nomScientifique= "Inconnu", string esperanceVie = "Inconnue", string poidsMoyen = "Inconnu", string tailleMoyenne = "Inconnue", string comportement = "Inconnu", string sante = "Inconnue", string education = "Inconnue", string entretien = "Inconnu", string cout = "Inconnu", string conseil = "Inconnu", string? image = null) { Nom = nom; NomScientifique = nomScientifique; @@ -69,6 +69,7 @@ namespace Model Entretien = entretien; Cout = cout; Conseil = conseil; + Image = image; } /*! diff --git a/Sources/Tests/Tests.csproj b/Sources/Tests/Tests.csproj new file mode 100644 index 0000000..7898cb8 --- /dev/null +++ b/Sources/Tests/Tests.csproj @@ -0,0 +1,29 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/Sources/Tests/Tests_race.cs b/Sources/Tests/Tests_race.cs new file mode 100644 index 0000000..38cb415 --- /dev/null +++ b/Sources/Tests/Tests_race.cs @@ -0,0 +1,30 @@ +using System.Runtime.CompilerServices; +using Model; +using NuGet.Frameworks; + +namespace Tests +{ + public class Tests_race + { + [Theory] + [InlineData("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", null, null)] + [InlineData("American curl", "American curl", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Un petit conseil", "Un petit conseil", null, null)] + [InlineData("Abyssin", "Abyssin", "Felis catus", "Felis catus", "15 à 20 ans", "15 à 20 ans", "2.7 à 5.5 kg", "2.7 à 5.5 kg", "30 à 45 cm", "30 à 45 cm", "Son comportement", "Son comportement", "Sa santé", "Sa santé", "Son éducation", "Son éducation", "Son entretien", "Son entretien", "Son cout", "Son cout", "Un petit conseil", "Un petit conseil", "abyssin.png", "abyssin.png")] + public void TestConstructor(string nom, string expectedNom, string nomScientifique, string exceptedNomScientifique, string esperanceVie, string exceptedEsperanceVie, string poidsMoyen, string exceptedPoidsMoyen, string tailleMoyenne, string exceptedTailleMoyenne, string comportement, string exceptedComportement, string sante, string exceptedSante, string education, string exceptedEducation, string entretien, string exceptedEntretien, string cout, string exceptedCout, string conseil, string exceptedConseil, string? image, string? exceptedImage) + { + Race e = new Race(nom, nomScientifique, esperanceVie, poidsMoyen, tailleMoyenne, comportement, sante, education, entretien, cout, conseil, image); + Assert.Equal(expectedNom, e.Nom); + Assert.Equal(exceptedNomScientifique, e.NomScientifique); + Assert.Equal(exceptedEsperanceVie, e.EsperanceVie); + Assert.Equal(exceptedPoidsMoyen, e.PoidsMoyen); + Assert.Equal(exceptedTailleMoyenne, e.TailleMoyenne); + Assert.Equal(exceptedComportement, e.Comportement); + Assert.Equal(exceptedSante, e.Sante); + Assert.Equal(exceptedEducation, e.Education); + Assert.Equal(exceptedEntretien, e.Entretien); + Assert.Equal(exceptedCout, e.Cout); + Assert.Equal(exceptedConseil, e.Conseil); + Assert.Equal(exceptedImage, e.Image); + } + } +} \ No newline at end of file diff --git a/Sources/Tests/Usings.cs b/Sources/Tests/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/Sources/Tests/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/Sources/Wikipet's.sln b/Sources/Wikipet's.sln index e94d171..46e0d04 100644 --- a/Sources/Wikipet's.sln +++ b/Sources/Wikipet's.sln @@ -12,7 +12,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Views", "Views\Views.csproj {83309215-075B-406F-A72E-45E40AD47E43} = {83309215-075B-406F-A72E-45E40AD47E43} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Persistance", "Persistance\Persistance.csproj", "{E056C06A-C2FF-40FE-A8B2-CE581F415BB6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistance", "Persistance\Persistance.csproj", "{E056C06A-C2FF-40FE-A8B2-CE581F415BB6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{4BFD8DFB-D72D-406E-8E66-F23099FD974F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -118,6 +120,26 @@ Global {E056C06A-C2FF-40FE-A8B2-CE581F415BB6}.Release|x64.Build.0 = Release|Any CPU {E056C06A-C2FF-40FE-A8B2-CE581F415BB6}.Release|x86.ActiveCfg = Release|Any CPU {E056C06A-C2FF-40FE-A8B2-CE581F415BB6}.Release|x86.Build.0 = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|ARM.ActiveCfg = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|ARM.Build.0 = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|ARM64.Build.0 = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|x64.ActiveCfg = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|x64.Build.0 = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|x86.ActiveCfg = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Debug|x86.Build.0 = Debug|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|Any CPU.Build.0 = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|ARM.ActiveCfg = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|ARM.Build.0 = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|ARM64.ActiveCfg = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|ARM64.Build.0 = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|x64.ActiveCfg = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|x64.Build.0 = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|x86.ActiveCfg = Release|Any CPU + {4BFD8DFB-D72D-406E-8E66-F23099FD974F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE