diff --git a/Sources/Model/Bestiaire.cs b/Sources/Model/Bestiaire.cs index 00731e5..065262a 100644 --- a/Sources/Model/Bestiaire.cs +++ b/Sources/Model/Bestiaire.cs @@ -15,7 +15,7 @@ namespace Model public string Caracteristique { get; set; } - public Bestiaire(string nom, string origine, string description, string caracteristique,string image) : base(nom, image) + public Bestiaire(string nom, string origine, string description, string caracteristique,string image = "baseimage.png") : base(nom, image) { Origine = origine; Description = description; diff --git a/Sources/Model/Equipage.cs b/Sources/Model/Equipage.cs index 9b386d5..0e603f7 100644 --- a/Sources/Model/Equipage.cs +++ b/Sources/Model/Equipage.cs @@ -20,13 +20,27 @@ namespace Model public List Allie { get; set; } = new List(); - public Equipage(string nom, string nomRomanise, string region, int premierChap, int premierEp, bool statut, string description,string image) : base(nom,image) + public Equipage(string nom, string nomRomanise, string region, int premierChap, int premierEp, bool statut, string description,string image = "baseimage.png") : base(nom,image) { NomRomanise = nomRomanise; Region = region; - PremierChap = premierChap; - PremierEp = premierEp; + if(premierEp < 0) + { + PremierEp = 0; + } + else + { + PremierEp = premierEp; + } + if(premierChap < 0) + { + premierChap = 0; + } + else + { + PremierChap = premierChap; + } Statut = statut; Description = description; diff --git a/Sources/Model/FruitDuDemon.cs b/Sources/Model/FruitDuDemon.cs index fce2c01..b24877b 100644 --- a/Sources/Model/FruitDuDemon.cs +++ b/Sources/Model/FruitDuDemon.cs @@ -20,7 +20,7 @@ namespace Model - public FruitDuDemon(string nom, string nomRomanise, string type, int premierChap, int premierEp, string description, string forces, string faiblesses, string image) : base(nom,image) + public FruitDuDemon(string nom, string nomRomanise, string type, int premierChap, int premierEp, string description, string forces, string faiblesses, string image = "baseimage.png") : base(nom,image) { NomRomanise = nomRomanise; diff --git a/Sources/Model/Ile.cs b/Sources/Model/Ile.cs index 14fb050..ecd81ee 100644 --- a/Sources/Model/Ile.cs +++ b/Sources/Model/Ile.cs @@ -18,7 +18,7 @@ namespace Model - public Ile(string nom, string nomRomanise, string region, int premierChap, int premierEp, string description, string geographie, string image) : base(nom,image) + public Ile(string nom, string nomRomanise, string region, int premierChap, int premierEp, string description, string geographie, string image = "baseimage.png") : base(nom,image) { NomRomanise = nomRomanise; diff --git a/Sources/Model/ObjetOhara.cs b/Sources/Model/ObjetOhara.cs index 78ff8ea..a40b4fe 100644 --- a/Sources/Model/ObjetOhara.cs +++ b/Sources/Model/ObjetOhara.cs @@ -1,15 +1,19 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace Model { + [DataContract(Name = "objetohara")] public class ObjetOhara { + [DataMember] public string Nom { get; set; } - public string? Image { get; set;} + [DataMember (Name ="image")] + public string? Image { get; set;} public ObjetOhara(string nom,string image) { Nom = nom; diff --git a/Sources/Model/Personnage.cs b/Sources/Model/Personnage.cs index ec2b7b6..57cd166 100644 --- a/Sources/Model/Personnage.cs +++ b/Sources/Model/Personnage.cs @@ -1,5 +1,8 @@ -namespace Model +using System.Runtime.Serialization; + +namespace Model { + public class Personnage : ObjetOhara { @@ -16,10 +19,16 @@ - public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation, string image) : base(nom,image) + public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation, string image = "baseimage.png") : base(nom,image) { - - Prime = prime; + if(prime < 0) + { + Prime = 0; + } + else + { + Prime = prime; + } Epithete = epithete; Age = age; Taille = taille; diff --git a/Sources/Ohara/Resources/Images/baseimage.png b/Sources/Ohara/Resources/Images/baseimage.png new file mode 100644 index 0000000..74725dc Binary files /dev/null and b/Sources/Ohara/Resources/Images/baseimage.png differ diff --git a/Sources/TestConsole/Program.cs b/Sources/TestConsole/Program.cs index 54d0f67..2413482 100644 --- a/Sources/TestConsole/Program.cs +++ b/Sources/TestConsole/Program.cs @@ -3,6 +3,8 @@ using Model; var manager = new Manager(); -foreach (Bateau b in manager.GetBateaux()){ - Console.WriteLine(b.Nom); -} \ No newline at end of file +Bestiaire test = new Bestiaire("Humains", "??", "Les humains sont ...", "Ils possèdent les caractéristiques suivantes ..."); +Bestiaire test2 = new Bestiaire("Humains", "??", "Les humains sont ...", "Ils possèdent les caractéristiques suivantes ...","test"); + +Console.WriteLine(test.Image); +Console.WriteLine(test2.Image); \ No newline at end of file diff --git a/Sources/TestProject1/TestProject1.csproj b/Sources/TestProject1/TestProject1.csproj index 86a36ef..dedc487 100644 --- a/Sources/TestProject1/TestProject1.csproj +++ b/Sources/TestProject1/TestProject1.csproj @@ -21,4 +21,8 @@ + + + + diff --git a/Sources/TestProject1/UnitTest1.cs b/Sources/TestProject1/UnitTest1.cs index b0a7e4f..c8f4fdc 100644 --- a/Sources/TestProject1/UnitTest1.cs +++ b/Sources/TestProject1/UnitTest1.cs @@ -1,19 +1,34 @@ +using Model; using System.Reflection; using System.Security.Cryptography.X509Certificates; - - - namespace TestProject1 { public class UnitTest1 { [Fact] - public void ParametreEstPositif() + public void Personnage_PrimeSuperieurOuEgalAZero_ReturnTrue() + { + Personnage test = new Personnage("Luffy", -100, "Luffy au Chapeau de Paille", 19, 1.74, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png"); + bool resultat = (test.Prime >= 0); + Assert.True(resultat,"La prime doit avoir une valeur positive"); + } + [Fact] + public void Constructeurs_ImageEgaleValeurParDefaut_ReturnTrue() + { + Bestiaire test = new Bestiaire("Humains", "??", "Les humains sont ...", "Ils possèdent les caractéristiques suivantes ..."); + bool resultat = (test.Image == "baseimage.png"); + Assert.True(resultat,"L'image devrait avoir la valeur : baseImage.pnt"); + } + + [Fact] + public void Equipage_PremierChapEtPremierEpSuperieurOuEgalAZero_ReturnTrue() { - + Equipage test = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "roux.png"); + bool resultat = (test.PremierChap >= 0 && test.PremierEp >= 0); + Assert.True(resultat, "Les paramètre PremierChap et PremierEp doivent être supérieur ou égale à 0"); } } } \ No newline at end of file diff --git a/Sources/TestProject1/Usings.cs b/Sources/TestProject1/Usings.cs index 8c927eb..bf70be5 100644 --- a/Sources/TestProject1/Usings.cs +++ b/Sources/TestProject1/Usings.cs @@ -1 +1,3 @@ -global using Xunit; \ No newline at end of file +global using Xunit; +using TestProject1; +