Merge pull request 'Tests unitaires devYoan' (#15) from devYoan into master
continuous-integration/drone/push Build is passing Details

Reviewed-on: #15
master
Yoan BRUGIÈRE 2 years ago
commit 7aab5853da

@ -30,7 +30,7 @@ steps:
sonar_token: sonar_token:
from_secret: SECRET_SONAR_LOGIN from_secret: SECRET_SONAR_LOGIN
project_key: Ohara project_key: Ohara
coverage_exclusions: "Tests/**" coverage_exclusions: Tests/**,Ohara/**
commands: commands:
- cd Sources/ - cd Sources/
- dotnet restore Ohara.sln - dotnet restore Ohara.sln

@ -132,7 +132,7 @@ namespace Model.Classes
} }
if (premierChap < 0) if (premierChap < 0)
{ {
premierChap = 0; PremierChap = 0;
} }
else else
{ {

@ -158,7 +158,7 @@ namespace Model.Classes
public override int GetHashCode() public override int GetHashCode()
{ {
return HashCode.Combine(Prime, Epithete, Age, Origine,Biographie, Citation,Equipage,Fruit); return HashCode.Combine(Prime, Epithete, Age, Taille, Origine,Biographie, Citation,Equipage);
} }
public override string ToString() public override string ToString()

@ -9,12 +9,12 @@ namespace Model.Managers
{ {
public interface IDataManager public interface IDataManager
{ {
IEnumerable<Bateau> GetBateaux(); IEnumerable<Bateau>? GetBateaux();
IEnumerable<Bestiaire> GetBestiaires(); IEnumerable<Bestiaire>? GetBestiaires();
IEnumerable<Equipage> GetEquipages(); IEnumerable<Equipage>? GetEquipages();
IEnumerable<FruitDuDemon> GetFruits(); IEnumerable<FruitDuDemon>? GetFruits();
IEnumerable<Ile> GetIles(); IEnumerable<Ile>? GetIles();
IEnumerable<Personnage> GetPersonnages(); IEnumerable<Personnage>? GetPersonnages();
void SetBateau(List<Bateau> listeBateaux); void SetBateau(List<Bateau> listeBateaux);
void SetBestiaire(List<Bestiaire> listeBest); void SetBestiaire(List<Bestiaire> listeBest);
void SetEquipage(List<Equipage> listeEquip); void SetEquipage(List<Equipage> listeEquip);

@ -63,49 +63,62 @@ namespace Model.Managers
public Manager(IDataManager dataManager) public Manager(IDataManager dataManager)
{ {
DataManager = dataManager; DataManager = dataManager;
Bateaux = new ObservableCollection<Bateau>(DataManager.GetBateaux()); var bateaux = DataManager.GetBateaux();
Personnages = new ObservableCollection<Personnage>(DataManager.GetPersonnages()); Bateaux = bateaux != null ? new ObservableCollection<Bateau>(bateaux) : new ObservableCollection<Bateau>();
Fruits = new ObservableCollection<FruitDuDemon>(DataManager.GetFruits()); var personnages = DataManager.GetPersonnages();
Iles = new ObservableCollection<Ile>(DataManager.GetIles()); Personnages = personnages != null ? new ObservableCollection<Personnage>(personnages) : new ObservableCollection<Personnage>();
Bestiaire = new ObservableCollection<Bestiaire>(DataManager.GetBestiaires()); var fruits = DataManager.GetFruits();
Equipages = new ObservableCollection<Equipage>(DataManager.GetEquipages()); Fruits = fruits != null ? new ObservableCollection<FruitDuDemon>(fruits) : new ObservableCollection<FruitDuDemon>();
var iles = DataManager.GetIles();
Iles = iles != null ? new ObservableCollection<Ile>(iles) : new ObservableCollection<Ile>();
var bests = DataManager.GetBestiaires();
Bestiaire = bests != null ? new ObservableCollection<Bestiaire>(bests) : new ObservableCollection<Bestiaire>();
var equipages = DataManager.GetEquipages();
Equipages = equipages != null ? new ObservableCollection<Equipage>(equipages) : new ObservableCollection<Equipage>();
} }
/// \brief Récupère la liste des personnages. /// \brief Récupère la liste des personnages.
/// \return La liste des personnages. /// \return La liste des personnages.
public List<Personnage> GetPersonnages() public List<Personnage> GetPersonnages()
{ {
return DataManager.GetPersonnages().ToList(); var personnages = DataManager.GetPersonnages();
return personnages != null ? personnages.ToList() : new List<Personnage>();
} }
/// \brief Récupère la liste des fruits du démon. /// \brief Récupère la liste des fruits du démon.
/// \return La liste des fruits du démon. /// \return La liste des fruits du démon.
public List<FruitDuDemon> GetFruits() public List<FruitDuDemon> GetFruits()
{ {
return DataManager.GetFruits().ToList(); var fruits = DataManager.GetFruits();
return fruits != null ? fruits.ToList() : new List<FruitDuDemon>();
} }
/// \brief Récupère la liste des équipages. /// \brief Récupère la liste des équipages.
/// \return La liste des équipages. /// \return La liste des équipages.
public List<Equipage> GetEquipages() public List<Equipage> GetEquipages()
{ {
return DataManager.GetEquipages().ToList(); var equipages = DataManager.GetEquipages();
return equipages != null ? equipages.ToList() : new List<Equipage>();
} }
/// \brief Récupère la liste des bateaux. /// \brief Récupère la liste des bateaux.
/// \return La liste des bateaux. /// \return La liste des bateaux.
public List<Bateau> GetBateaux() public List<Bateau> GetBateaux()
{ {
return DataManager.GetBateaux().ToList(); var bateaux = DataManager.GetBateaux();
return bateaux != null ? bateaux.ToList() : new List<Bateau>();
} }
/// \brief Récupère la liste des bestiaires. /// \brief Récupère la liste des bestiaires.
/// \return La liste des bestiaires. /// \return La liste des bestiaires.
public List<Bestiaire> GetBestiaires() public List<Bestiaire> GetBestiaires()
{ {
return DataManager.GetBestiaires().ToList(); var bestiaires = DataManager.GetBestiaires();
return bestiaires != null ? bestiaires.ToList() : new List<Bestiaire>();
} }
/// \brief Récupère la liste des îles. /// \brief Récupère la liste des îles.
/// \return La liste des îles. /// \return La liste des îles.
public List<Ile> GetIles() public List<Ile> GetIles()
{ {
return DataManager.GetIles().ToList(); var iles = DataManager.GetIles();
return iles != null ? iles.ToList() : new List<Ile>();
} }
/// \brief Filtre les fruits du démon par type. /// \brief Filtre les fruits du démon par type.
@ -113,17 +126,15 @@ namespace Model.Managers
/// \return La liste filtrée des fruits du démon. /// \return La liste filtrée des fruits du démon.
public List<FruitDuDemon> FiltrerFDD(string type) public List<FruitDuDemon> FiltrerFDD(string type)
{ {
List<FruitDuDemon> fdd = new List<FruitDuDemon>(); List<FruitDuDemon> fdd =Fruits.Where(p=>p.Type==type).ToList();
fdd=Fruits.Where(p=>p.Type==type).ToList();
return fdd; return fdd;
} }
/// \brief Filtre les bateaux par nom d'affiliation. /// \brief Filtre les bateaux par nom d'affiliation.
/// \param nom Le nom de l'équipage affilié au(x) bateau(x). /// \param nom Le nom de l'équipage affilié au(x) bateau(x).
/// \return La liste filtrée des bateaux. /// \return La liste filtrée des bateaux.
public List<Bateau> FiltrerBateau(string nom) public List<Bateau> FiltrerBateau(string nom)
{ {
List<Bateau> bateau = new List<Bateau>(); List<Bateau> bateau = Bateaux.Where(p => p.Affiliation?.Nom == nom).ToList();
bateau = Bateaux.Where(p => p.Affiliation?.Nom == nom).ToList();
return bateau; return bateau;
} }
/// \brief Filtre les îles par région. /// \brief Filtre les îles par région.
@ -131,8 +142,7 @@ namespace Model.Managers
/// \return La liste filtrée des îles. /// \return La liste filtrée des îles.
public List<Ile> FiltrerIle(string region) public List<Ile> FiltrerIle(string region)
{ {
List<Ile> ile = new List<Ile>(); List<Ile> ile = Iles.Where(p => p.Region == region).ToList();
ile = Iles.Where(p => p.Region == region).ToList();
return ile; return ile;
} }
/// \brief Recherche les objets Ohara correspondant au texte donné. /// \brief Recherche les objets Ohara correspondant au texte donné.
@ -171,15 +181,15 @@ namespace Model.Managers
} }
/// \brief Récupère la liste des objets Ohara ayant le parametre EstFavori égal a true. /// \brief Récupère la liste des objets Ohara ayant le parametre EstFavori égal a true.
/// \return La liste des objets Ohara ayant le parametre EstFavori égal a true. /// \return La liste des objets Ohara ayant le parametre EstFavori égal a true.
public List<ObjetOhara> GetFavoris() public HashSet<ObjetOhara> GetFavoris()
{ {
List<ObjetOhara> listeFavoris = new List<ObjetOhara>(); HashSet<ObjetOhara> listeFavoris = new HashSet<ObjetOhara>();
listeFavoris.AddRange(Bateaux); listeFavoris.UnionWith(Bateaux);
listeFavoris.AddRange(Equipages); listeFavoris.UnionWith(Equipages);
listeFavoris.AddRange(Bestiaire); listeFavoris.UnionWith(Bestiaire);
listeFavoris.AddRange(Fruits); listeFavoris.UnionWith(Fruits);
listeFavoris.AddRange(Iles); listeFavoris.UnionWith(Iles);
listeFavoris.AddRange(Personnages); listeFavoris.UnionWith(Personnages);
foreach(ObjetOhara obj in listeFavoris.ToList()) foreach(ObjetOhara obj in listeFavoris.ToList())
{ {
if (obj.EstFavori == false) if (obj.EstFavori == false)

@ -30,27 +30,39 @@ namespace Model.Serializer
{ {
if (!File.Exists(Path.Combine(Chemin, "./personnage.xml"))) if (!File.Exists(Path.Combine(Chemin, "./personnage.xml")))
{ {
SetPersonnage(stubManager.GetPersonnages().ToList()); var personnages = stubManager.GetPersonnages();
if(personnages!=null)
SetPersonnage(personnages.ToList());
} }
if (!File.Exists(Path.Combine(Chemin, "./bateau.xml"))) if (!File.Exists(Path.Combine(Chemin, "./bateau.xml")))
{ {
SetBateau(stubManager.GetBateaux().ToList()); var bateaux = stubManager.GetBateaux();
if(bateaux !=null)
SetBateau(bateaux.ToList());
} }
if (!File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml"))) if (!File.Exists(Path.Combine(Chemin, "./fruitdudemon.xml")))
{ {
SetFDD(stubManager.GetFruits().ToList()); var fruits = stubManager.GetFruits();
if(fruits!=null)
SetFDD(fruits.ToList());
} }
if (!File.Exists(Path.Combine(Chemin, "./bestiaire.xml"))) if (!File.Exists(Path.Combine(Chemin, "./bestiaire.xml")))
{ {
SetBestiaire(stubManager.GetBestiaires().ToList()); var bestiaires= stubManager.GetBestiaires();
if(bestiaires!=null)
SetBestiaire(bestiaires.ToList());
} }
if (!File.Exists(Path.Combine(Chemin, "./equipage.xml"))) if (!File.Exists(Path.Combine(Chemin, "./equipage.xml")))
{ {
SetEquipage(stubManager.GetEquipages().ToList()); var equipages= stubManager.GetEquipages();
if(equipages!=null)
SetEquipage(equipages.ToList());
} }
if (!File.Exists(Path.Combine(Chemin, "./ile.xml"))) if (!File.Exists(Path.Combine(Chemin, "./ile.xml")))
{ {
SetIle(stubManager.GetIles().ToList()); var iles = stubManager.GetIles();
if(iles!=null)
SetIle(iles.ToList());
} }
} }
@ -143,7 +155,7 @@ namespace Model.Serializer
} }
} }
public void SetBateau(List<Bateau> listeBateau) public void SetBateau(List<Bateau> listeBateaux)
{ {
var serializer = new DataContractSerializer(typeof(List<Bateau>)); var serializer = new DataContractSerializer(typeof(List<Bateau>));
string xmlFile = "bateau.xml"; string xmlFile = "bateau.xml";
@ -155,92 +167,80 @@ namespace Model.Serializer
using (XmlWriter writer = XmlWriter.Create(tw, settings)) using (XmlWriter writer = XmlWriter.Create(tw, settings))
{ {
serializer.WriteObject(writer, listeBateau); serializer.WriteObject(writer, listeBateaux);
} }
} }
} }
public IEnumerable<Bateau> GetBateaux() public IEnumerable<Bateau>? GetBateaux()
{ {
List<Bateau>? listeBateau = new List<Bateau>();
var serializer = new DataContractSerializer(typeof(List<Bateau>)); var serializer = new DataContractSerializer(typeof(List<Bateau>));
string xmlFile = "bateau.xml"; string xmlFile = "bateau.xml";
Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); Directory.SetCurrentDirectory(Path.Combine(Chemin, "./"));
using (Stream s = File.OpenRead(xmlFile)) using (Stream s = File.OpenRead(xmlFile))
{ {
listeBateau = serializer.ReadObject(s) as List<Bateau>; return serializer.ReadObject(s) as List<Bateau>;
} }
return listeBateau;
} }
public IEnumerable<Bestiaire> GetBestiaires() public IEnumerable<Bestiaire>? GetBestiaires()
{ {
List<Bestiaire>? listeBest = new List<Bestiaire>();
var serializer = new DataContractSerializer(typeof(List<Bestiaire>)); var serializer = new DataContractSerializer(typeof(List<Bestiaire>));
string xmlFile = "bestiaire.xml"; string xmlFile = "bestiaire.xml";
Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); Directory.SetCurrentDirectory(Path.Combine(Chemin, "./"));
using (Stream s = File.OpenRead(xmlFile)) using (Stream s = File.OpenRead(xmlFile))
{ {
listeBest = serializer.ReadObject(s) as List<Bestiaire>; return serializer.ReadObject(s) as List<Bestiaire>;
} }
return listeBest;
} }
public IEnumerable<Equipage> GetEquipages() public IEnumerable<Equipage>? GetEquipages()
{ {
List<Equipage>? listeEquip = new List<Equipage>();
var serializer = new DataContractSerializer(typeof(List<Equipage>)); var serializer = new DataContractSerializer(typeof(List<Equipage>));
string xmlFile = "equipage.xml"; string xmlFile = "equipage.xml";
Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); Directory.SetCurrentDirectory(Path.Combine(Chemin, "./"));
using (Stream s = File.OpenRead(xmlFile)) using (Stream s = File.OpenRead(xmlFile))
{ {
listeEquip = serializer.ReadObject(s) as List<Equipage>; return serializer.ReadObject(s) as List<Equipage>;
} }
return listeEquip;
} }
public IEnumerable<FruitDuDemon> GetFruits() public IEnumerable<FruitDuDemon>? GetFruits()
{ {
List<FruitDuDemon>? listeFDD = new List<FruitDuDemon>();
var serializer = new DataContractSerializer(typeof(List<FruitDuDemon>)); var serializer = new DataContractSerializer(typeof(List<FruitDuDemon>));
string xmlFile = "fruitdudemon.xml"; string xmlFile = "fruitdudemon.xml";
Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); Directory.SetCurrentDirectory(Path.Combine(Chemin, "./"));
using (Stream s = File.OpenRead(xmlFile)) using (Stream s = File.OpenRead(xmlFile))
{ {
listeFDD = serializer.ReadObject(s) as List<FruitDuDemon>; return serializer.ReadObject(s) as List<FruitDuDemon>;
} }
return listeFDD;
} }
public IEnumerable<Ile> GetIles() public IEnumerable<Ile>? GetIles()
{ {
List<Ile>? listeIle = new List<Ile>();
var serializer = new DataContractSerializer(typeof(List<Ile>)); var serializer = new DataContractSerializer(typeof(List<Ile>));
string xmlFile = "ile.xml"; string xmlFile = "ile.xml";
Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); Directory.SetCurrentDirectory(Path.Combine(Chemin, "./"));
using (Stream s = File.OpenRead(xmlFile)) using (Stream s = File.OpenRead(xmlFile))
{ {
listeIle = serializer.ReadObject(s) as List<Ile>; return serializer.ReadObject(s) as List<Ile>;
} }
return listeIle;
} }
public IEnumerable<Personnage> GetPersonnages() public IEnumerable<Personnage>? GetPersonnages()
{ {
List<Personnage>? listePerso = new List<Personnage>();
var serializer = new DataContractSerializer(typeof(List<Personnage>)); var serializer = new DataContractSerializer(typeof(List<Personnage>));
string xmlFile = "personnage.xml"; string xmlFile = "personnage.xml";
Directory.SetCurrentDirectory(Path.Combine(Chemin, "./")); Directory.SetCurrentDirectory(Path.Combine(Chemin, "./"));
using (Stream s = File.OpenRead(xmlFile)) using (Stream s = File.OpenRead(xmlFile))
{ {
listePerso = serializer.ReadObject(s) as List<Personnage>; return serializer.ReadObject(s) as List<Personnage>;
} }
return listePerso;
} }
} }
} }

@ -30,31 +30,31 @@ namespace Model.Stub
} }
public IEnumerable<Personnage> GetPersonnages() public IEnumerable<Personnage>? GetPersonnages()
{ {
return StubPersonnage.RecupererPersonnage(); return StubPersonnage.RecupererPersonnage();
} }
public IEnumerable<FruitDuDemon> GetFruits() public IEnumerable<FruitDuDemon>? GetFruits()
{ {
return StubFruitDuDemon.RecupererFruit(); return StubFruitDuDemon.RecupererFruit();
} }
public IEnumerable<Equipage> GetEquipages() public IEnumerable<Equipage>? GetEquipages()
{ {
StubEquipage.ChargerEquipage(StubPersonnage.RecupererPersonnage().ToList()); StubEquipage.ChargerEquipage(StubPersonnage.RecupererPersonnage().ToList());
return StubEquipage.RecupererEquipage(); return StubEquipage.RecupererEquipage();
} }
public IEnumerable<Bateau> GetBateaux() public IEnumerable<Bateau>? GetBateaux()
{ {
return StubBateau.RecupererBateau(); return StubBateau.RecupererBateau();
} }
public IEnumerable<Bestiaire> GetBestiaires() public IEnumerable<Bestiaire>? GetBestiaires()
{ {
return StubBestiaire.RecupererBestiaire(); return StubBestiaire.RecupererBestiaire();
} }
public IEnumerable<Ile> GetIles() public IEnumerable<Ile>? GetIles()
{ {
return StubIle.RecupererIle(); return StubIle.RecupererIle();
} }

@ -12,6 +12,7 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProject1", "TestProject1\TestProject1.csproj", "{4AD3B218-1007-4859-BC93-2B3E957632E0}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProject1", "TestProject1\TestProject1.csproj", "{4AD3B218-1007-4859-BC93-2B3E957632E0}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{A0307D66-E621-4BC1-A239-87C9021E7CFD} = {A0307D66-E621-4BC1-A239-87C9021E7CFD} {A0307D66-E621-4BC1-A239-87C9021E7CFD} = {A0307D66-E621-4BC1-A239-87C9021E7CFD}
{EEC24A76-0EB3-4C67-A71B-7FF823713645} = {EEC24A76-0EB3-4C67-A71B-7FF823713645}
EndProjectSection EndProjectSection
EndProject EndProject
Global Global

@ -4,10 +4,9 @@ using Model;
public partial class AppShell : Shell public partial class AppShell : Shell
{ {
public AppShell() public AppShell()
{ {
InitializeComponent(); InitializeComponent();
} }
} }

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ohara.Converters
{
public class Int2ColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not int) return Colors.Red;
switch (value)
{
case < 0:
return Colors.Orange;
case >0:
return Colors.Green;
default:
return Colors.White;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -2,9 +2,13 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Ohara.ModalBateau" x:Class="Ohara.ModalBateau"
xmlns:conv="clr-namespace:Ohara.Converters"
Title="ModalBateau" Title="ModalBateau"
BackgroundColor="#e2edf1" BackgroundColor="#e2edf1"
Shell.PresentationMode="ModalAnimated"> Shell.PresentationMode="ModalAnimated">
<ContentPage.Resources>
<conv:Int2ColorConverter x:Key="int2ColorConverter"/>
</ContentPage.Resources>
<ScrollView> <ScrollView>
<FlexLayout AlignItems="End" Wrap="Wrap" Direction="Row" JustifyContent="Center" HorizontalOptions="Center" VerticalOptions="Center" > <FlexLayout AlignItems="End" Wrap="Wrap" Direction="Row" JustifyContent="Center" HorizontalOptions="Center" VerticalOptions="Center" >
<VerticalStackLayout Spacing="4" Margin="2"> <VerticalStackLayout Spacing="4" Margin="2">
@ -24,13 +28,13 @@
</Grid> </Grid>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Premier Chapitre :" FontAttributes="Bold"/> <Label Text="Premier Chapitre :" FontAttributes="Bold" TextColor="{Binding PremierChap, Converter={StaticResource int2ColorConverter}}"/>
<Entry Text="{Binding PremierChap}" /> <Entry Text="{Binding PremierChap}" />
</HorizontalStackLayout> </HorizontalStackLayout>
</Frame> </Frame>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Premier Episode :" FontAttributes="Bold"/> <Label Text="Premier Episode :" FontAttributes="Bold" TextColor="{Binding PremierEp, Converter={StaticResource int2ColorConverter}}"/>
<Entry Text="{Binding PremierEp}" /> <Entry Text="{Binding PremierEp}" />
</HorizontalStackLayout > </HorizontalStackLayout >
</Frame> </Frame>

@ -1,3 +1,4 @@
using Model.Classes; using Model.Classes;
using Model.Managers; using Model.Managers;
@ -27,12 +28,23 @@ public partial class ModalBateau : ContentPage
{ {
if (manager.SelectedItem != null) if (manager.SelectedItem != null)
{ {
if (nouveauBateau.PremierChap < 0 || nouveauBateau.PremierEp < 0)
{
await DisplayAlert("Erreur", "Les paramètres PremierChap et PremierEp doivent être superieur à 0.", "OK");
return;
}
manager.ModifierBateau(nouveauBateau, ancienNom); manager.ModifierBateau(nouveauBateau, ancienNom);
nouveauBateau = manager.SelectedItem as Bateau; nouveauBateau = manager.SelectedItem as Bateau;
} }
else else
{ {
if (nouveauBateau.PremierChap<0 || nouveauBateau.PremierEp < 0)
{
await DisplayAlert("Erreur", "Les paramètres PremierChap et PremierEp doivent être superieur à 0.", "OK");
return;
}
manager.AjouterBateau(nouveauBateau); manager.AjouterBateau(nouveauBateau);
} }
await Navigation.PopModalAsync(); await Navigation.PopModalAsync();

@ -2,9 +2,13 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Ohara.ModalEquipage" x:Class="Ohara.ModalEquipage"
xmlns:conv="clr-namespace:Ohara.Converters"
Title="ModalEquipage" Title="ModalEquipage"
BackgroundColor="#e2edf1" BackgroundColor="#e2edf1"
Shell.PresentationMode="ModalAnimated"> Shell.PresentationMode="ModalAnimated">
<ContentPage.Resources>
<conv:Int2ColorConverter x:Key="int2ColorConverter"/>
</ContentPage.Resources>
<ScrollView> <ScrollView>
<FlexLayout AlignItems="End" Wrap="Wrap" Direction="Row" JustifyContent="Center" HorizontalOptions="Center" VerticalOptions="Center" > <FlexLayout AlignItems="End" Wrap="Wrap" Direction="Row" JustifyContent="Center" HorizontalOptions="Center" VerticalOptions="Center" >
<VerticalStackLayout Spacing="4" Margin="2"> <VerticalStackLayout Spacing="4" Margin="2">
@ -36,13 +40,13 @@
</Frame> </Frame>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Premier Chapitre :" FontAttributes="Bold"/> <Label Text="Premier Chapitre :" FontAttributes="Bold" TextColor="{Binding PremierChap, Converter={StaticResource int2ColorConverter}}"/>
<Entry Text="{Binding PremierChap}" /> <Entry Text="{Binding PremierChap}" />
</HorizontalStackLayout> </HorizontalStackLayout>
</Frame> </Frame>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Premier Episode :" FontAttributes="Bold"/> <Label Text="Premier Episode :" FontAttributes="Bold" TextColor="{Binding PremierEp, Converter={StaticResource int2ColorConverter}}"/>
<Entry Text="{Binding PremierEp}" /> <Entry Text="{Binding PremierEp}" />
</HorizontalStackLayout > </HorizontalStackLayout >
</Frame> </Frame>

@ -30,11 +30,21 @@ public partial class ModalEquipage : ContentPage
{ {
if (manager.SelectedItem != null) if (manager.SelectedItem != null)
{ {
if (nouvelEquipage.PremierChap < 0 || nouvelEquipage.PremierEp < 0)
{
await DisplayAlert("Erreur", "Les paramètres PremierChap et PremierEp doivent être superieur à 0.", "OK");
return;
}
manager.ModifierEquipage(nouvelEquipage, ancienNom); manager.ModifierEquipage(nouvelEquipage, ancienNom);
nouvelEquipage = manager.SelectedItem as Equipage; nouvelEquipage = manager.SelectedItem as Equipage;
} }
else else
{ {
if (nouvelEquipage.PremierChap < 0 || nouvelEquipage.PremierEp < 0)
{
await DisplayAlert("Erreur", "Les paramètres PremierChap et PremierEp doivent être superieur à 0.", "OK");
return;
}
manager.AjouterEquip(nouvelEquipage); manager.AjouterEquip(nouvelEquipage);
} }

@ -2,9 +2,13 @@
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Ohara.ModalIle" x:Class="Ohara.ModalIle"
xmlns:conv="clr-namespace:Ohara.Converters"
Title="ModalIle" Title="ModalIle"
BackgroundColor="#e2edf1" BackgroundColor="#e2edf1"
Shell.PresentationMode="ModalAnimated"> Shell.PresentationMode="ModalAnimated">
<ContentPage.Resources>
<conv:Int2ColorConverter x:Key="int2ColorConverter"/>
</ContentPage.Resources>
<ScrollView> <ScrollView>
<FlexLayout AlignItems="End" Wrap="Wrap" Direction="Row" JustifyContent="Center" HorizontalOptions="Center" VerticalOptions="Center" > <FlexLayout AlignItems="End" Wrap="Wrap" Direction="Row" JustifyContent="Center" HorizontalOptions="Center" VerticalOptions="Center" >
<VerticalStackLayout Spacing="4" Margin="2"> <VerticalStackLayout Spacing="4" Margin="2">
@ -36,13 +40,13 @@
</Frame> </Frame>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Premier Chapitre :" FontAttributes="Bold"/> <Label Text="Premier Chapitre :" FontAttributes="Bold" TextColor="{Binding PremierChap, Converter={StaticResource int2ColorConverter}}"/>
<Entry Text="{Binding PremierChap}" /> <Entry Text="{Binding PremierChap}" />
</HorizontalStackLayout> </HorizontalStackLayout>
</Frame> </Frame>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Premier Episode :" FontAttributes="Bold"/> <Label Text="Premier Episode :" FontAttributes="Bold" TextColor="{Binding PremierEp, Converter={StaticResource int2ColorConverter}}"/>
<Entry Text="{Binding PremierEp}" /> <Entry Text="{Binding PremierEp}" />
</HorizontalStackLayout > </HorizontalStackLayout >
</Frame> </Frame>

@ -29,11 +29,21 @@ public partial class ModalIle : ContentPage
{ {
if (manager.SelectedItem != null) if (manager.SelectedItem != null)
{ {
if (nouvelIle.PremierChap < 0 || nouvelIle.PremierEp < 0)
{
await DisplayAlert("Erreur", "Les paramètres PremierChap et PremierEp doivent être superieur à 0.", "OK");
return;
}
manager.ModifierIle(nouvelIle,ancienNom); manager.ModifierIle(nouvelIle,ancienNom);
manager.SelectedItem=nouvelIle; manager.SelectedItem=nouvelIle;
} }
else else
{ {
if (nouvelIle.PremierChap < 0 || nouvelIle.PremierEp < 0)
{
await DisplayAlert("Erreur", "Les paramètres PremierChap et PremierEp doivent être superieur à 0.", "OK");
return;
}
manager.AjouterIle(nouvelIle); manager.AjouterIle(nouvelIle);
} }

@ -8,7 +8,7 @@
BackgroundColor="#e2edf1"> BackgroundColor="#e2edf1">
<VerticalStackLayout Spacing="40"> <VerticalStackLayout >
<Grid ColumnDefinitions="200,*,100,10,150" BackgroundColor="#72a3b3" Padding="10"> <Grid ColumnDefinitions="200,*,100,10,150" BackgroundColor="#72a3b3" Padding="10">
<SearchBar x:Name="searchBar" Placeholder="Rechercher..." BackgroundColor="#bfe5ef" Grid.Column="0"/> <SearchBar x:Name="searchBar" Placeholder="Rechercher..." BackgroundColor="#bfe5ef" Grid.Column="0"/>
<Button Text="Ajouter" Clicked="Button_Clicked" Style="{StaticResource buttonBarre}" Grid.Column="4"/> <Button Text="Ajouter" Clicked="Button_Clicked" Style="{StaticResource buttonBarre}" Grid.Column="4"/>
@ -18,35 +18,20 @@
<CollectionView x:Name="listeBateau" ItemsSource="{Binding Bateaux}" ItemsLayout="HorizontalList" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listeBateau_SelectionChanged" > <CollectionView x:Name="listeBateau" ItemsSource="{Binding Bateaux}" ItemsLayout="HorizontalList" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listeBateau_SelectionChanged" >
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid Padding="50" ColumnSpacing="10"> <Grid Padding="50" ColumnSpacing="10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="400"/> <ColumnDefinition Width="400"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="750"/> <RowDefinition Height="80*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Frame Style="{StaticResource frameObjet3}" HeightRequest="800" WidthRequest="450">
<Frame
CornerRadius="25"
BorderColor="#e2edf1"
IsClippedToBounds="True"
Padding="0"
HeightRequest="800"
WidthRequest="450">
<Image <Image
Source="{Binding Image}" Source="{Binding Image}"
Aspect="Fill" Aspect="Fill"
/> />
</Frame> </Frame>
<Frame Style="{StaticResource frameObjet2}"> <Frame Style="{StaticResource frameObjet2}">
<StackLayout Orientation="Vertical" Spacing="25" VerticalOptions="Center"> <StackLayout Orientation="Vertical" Spacing="25" VerticalOptions="Center">
<Label <Label
Text="{Binding Nom}" Text="{Binding Nom}"

@ -13,7 +13,8 @@
</Grid> </Grid>
<FlexLayout x:Name="listeFav" AlignItems="Center" Wrap="Wrap" <FlexLayout x:Name="listeFav" AlignItems="Center" Wrap="Wrap"
HorizontalOptions="Center" JustifyContent="SpaceEvenly"> HorizontalOptions="Center" JustifyContent="SpaceEvenly"
>
<BindableLayout.ItemTemplate> <BindableLayout.ItemTemplate>
<DataTemplate> <DataTemplate>
<Frame Style="{StaticResource frameObjet}" Margin="0,10,0,0" > <Frame Style="{StaticResource frameObjet}" Margin="0,10,0,0" >
@ -37,6 +38,19 @@
</Frame> </Frame>
</DataTemplate> </DataTemplate>
</BindableLayout.ItemTemplate> </BindableLayout.ItemTemplate>
<BindableLayout.EmptyView>
<ContentView>
<StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<Label Text="Vous n'avez pas encore ajoutez d'objets à vos favoris ..."
TextColor="#72a3b3"
FontAttributes="Bold"
Margin="50"
FontSize="18"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"/>
</StackLayout>
</ContentView>
</BindableLayout.EmptyView>
</FlexLayout> </FlexLayout>
</VerticalStackLayout> </VerticalStackLayout>

@ -15,7 +15,7 @@ public partial class PageFavoris : ContentPage
void OnTextChanged(object sender, EventArgs e) void OnTextChanged(object sender, EventArgs e)
{ {
SearchBar searchBar = (SearchBar)sender; SearchBar searchBar = (SearchBar)sender;
BindableLayout.SetItemsSource(listeFav, manager.RechercheObjetOhara(searchBar.Text, manager.GetFavoris())); BindableLayout.SetItemsSource(listeFav, manager.RechercheObjetOhara(searchBar.Text, manager.GetFavoris().ToList()));
} }
searchBar.TextChanged += OnTextChanged; searchBar.TextChanged += OnTextChanged;

@ -6,7 +6,7 @@
Title="PageIle" Title="PageIle"
Appearing="ContentPage_Appearing" Appearing="ContentPage_Appearing"
BackgroundColor="#e2edf1"> BackgroundColor="#e2edf1">
<VerticalStackLayout Spacing="40"> <VerticalStackLayout>
<Grid ColumnDefinitions="200,*,100,10,150" BackgroundColor="#72a3b3" Padding="10"> <Grid ColumnDefinitions="200,*,100,10,150" BackgroundColor="#72a3b3" Padding="10">
<SearchBar x:Name="searchBar" Placeholder="Rechercher..." Style="{StaticResource searchBarOhara}" Grid.Column="0"/> <SearchBar x:Name="searchBar" Placeholder="Rechercher..." Style="{StaticResource searchBarOhara}" Grid.Column="0"/>
<Button Text="Ajouter" Clicked="Button_Clicked" Style="{StaticResource buttonBarre}" Grid.Column="4"/> <Button Text="Ajouter" Clicked="Button_Clicked" Style="{StaticResource buttonBarre}" Grid.Column="4"/>
@ -32,15 +32,9 @@
<ColumnDefinition Width="400"/> <ColumnDefinition Width="400"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="750"/> <RowDefinition Height="80*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Frame <Frame Style="{StaticResource frameObjet3}" HeightRequest="800" WidthRequest="450">
CornerRadius="25"
BorderColor="#e2edf1"
IsClippedToBounds="True"
Padding="0"
HeightRequest="800"
WidthRequest="450">
<Image <Image
Source="{Binding Image}" Source="{Binding Image}"

@ -3,8 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Ohara.PageInfoBateau" x:Class="Ohara.PageInfoBateau"
Title="PageInfoBateau" Title="PageInfoBateau"
BackgroundColor="#e2edf1"> BackgroundColor="#e2edf1"
<ScrollView Grid.Row="0" Grid.Column="1" Orientation="Vertical" VerticalScrollBarVisibility="Always"> >
<ScrollView Orientation="Vertical" VerticalScrollBarVisibility="Always">
<VerticalStackLayout Spacing="10" Padding="40"> <VerticalStackLayout Spacing="10" Padding="40">

@ -78,7 +78,7 @@
<Label Text="Membre(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/> <Label Text="Membre(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/>
<Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" /> <Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" />
<ScrollView Orientation="Horizontal"> <ScrollView Orientation="Horizontal">
<CollectionView x:Name="listMembre" ItemsLayout="HorizontalList" ItemsSource="{Binding Membre}" EmptyView="Cet équipage n'à pas de membres..." SelectionMode="Single" SelectionChanged="listMembre_SelectionChanged" > <CollectionView x:Name="listMembre" ItemsLayout="HorizontalList" ItemsSource="{Binding Membre}" SelectionMode="Single" SelectionChanged="listMembre_SelectionChanged" >
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
@ -98,10 +98,20 @@
FontAttributes="Bold" /> FontAttributes="Bold" />
</StackLayout> </StackLayout>
</Frame> </Frame>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
<CollectionView.EmptyView>
<ContentView>
<StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<Label Text="Cet équipage n'à pas (encore) de membre."
TextColor="#72a3b3"
FontAttributes="Bold"
FontSize="18"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"/>
</StackLayout>
</ContentView>
</CollectionView.EmptyView>
</CollectionView> </CollectionView>
</ScrollView> </ScrollView>
</VerticalStackLayout> </VerticalStackLayout>
@ -133,7 +143,7 @@
<Label Text="Allié(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/> <Label Text="Allié(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/>
<Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" /> <Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" />
<CollectionView x:Name="listAlle" ItemsLayout="HorizontalList" ItemsSource="{Binding Allie}" EmptyView="Cet équipage n'à pas d'alliés..." SelectionMode="Single" SelectionChanged="listAlle_SelectionChanged"> <CollectionView x:Name="listAlle" ItemsLayout="HorizontalList" ItemsSource="{Binding Allie}" SelectionMode="Single" SelectionChanged="listAlle_SelectionChanged">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Frame Style="{StaticResource frameEquip}" Margin="5"> <Frame Style="{StaticResource frameEquip}" Margin="5">
@ -154,6 +164,18 @@
</Frame> </Frame>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
<CollectionView.EmptyView>
<ContentView>
<StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<Label Text="Cet équipage n'à pas (encore) d'allié."
TextColor="#72a3b3"
FontAttributes="Bold"
FontSize="18"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"/>
</StackLayout>
</ContentView>
</CollectionView.EmptyView>
</CollectionView> </CollectionView>
</VerticalStackLayout> </VerticalStackLayout>

@ -117,6 +117,18 @@
</Frame> </Frame>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
<CollectionView.EmptyView>
<ContentView>
<StackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<Label Text="Ce personnage n'à pas (encore) de fruit du démon."
TextColor="#72a3b3"
FontAttributes="Bold"
FontSize="18"
HorizontalOptions="Fill"
HorizontalTextAlignment="Center"/>
</StackLayout>
</ContentView>
</CollectionView.EmptyView>
</CollectionView> </CollectionView>
</VerticalStackLayout> </VerticalStackLayout>

@ -8,15 +8,13 @@
BackgroundColor="#e2edf1"> BackgroundColor="#e2edf1">
<VerticalStackLayout Spacing="10"> <VerticalStackLayout>
<Grid ColumnDefinitions="200,*,150" BackgroundColor="#72a3b3" Padding="10"> <Grid ColumnDefinitions="200,*,150" BackgroundColor="#72a3b3" Padding="10">
<SearchBar x:Name="searchBar" Placeholder="Rechercher..." BackgroundColor="#bfe5ef" Grid.Column="0"/> <SearchBar x:Name="searchBar" Placeholder="Rechercher..." BackgroundColor="#bfe5ef" Grid.Column="0"/>
<Button Text="Ajouter" Clicked="ButtonAjouter_Clicked" Style="{StaticResource buttonBarre}" Grid.Column="2"/> <Button Text="Ajouter" Clicked="ButtonAjouter_Clicked" Style="{StaticResource buttonBarre}" Grid.Column="2"/>
</Grid> </Grid>
<ScrollView Orientation="Horizontal" HorizontalScrollBarVisibility="Always"> <ScrollView Orientation="Horizontal" HorizontalScrollBarVisibility="Always" >
<CollectionView x:Name="listePerso" ItemsSource="{Binding Personnages}" ItemsLayout="HorizontalList" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listePerso_SelectionChanged"> <CollectionView x:Name="listePerso" ItemsSource="{Binding Personnages}" ItemsLayout="HorizontalList" EmptyView="Aucun résultat trouvé." SelectionMode="Single" SelectionChanged="listePerso_SelectionChanged">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
@ -30,16 +28,9 @@
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Frame CornerRadius="25" <Frame Style="{StaticResource frameObjet3}" HeightRequest="800" WidthRequest="450">
BorderColor="#e2edf1" <Image
IsClippedToBounds="True" Source="{Binding Image}"
Padding="0"
HeightRequest="800"
WidthRequest="450">
<Image
Source="{Binding Image}"
Aspect="Fill" Aspect="Fill"
/> />
</Frame> </Frame>

@ -87,7 +87,7 @@
</Style> </Style>
<Style TargetType="Editor"> <Style TargetType="Editor">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" /> <Setter Property="TextColor" Value="White" />
<Setter Property="BackgroundColor" Value="Transparent" /> <Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/> <Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14" /> <Setter Property="FontSize" Value="14" />
@ -109,7 +109,7 @@
</Style> </Style>
<Style TargetType="Entry"> <Style TargetType="Entry">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" /> <Setter Property="TextColor" Value="White" />
<Setter Property="BackgroundColor" Value="Transparent" /> <Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/> <Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14" /> <Setter Property="FontSize" Value="14" />
@ -158,7 +158,7 @@
</Style> </Style>
<Style TargetType="Label"> <Style TargetType="Label">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" /> <Setter Property="TextColor" Value="White" />
<Setter Property="BackgroundColor" Value="Transparent" /> <Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular" /> <Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" /> <Setter Property="FontSize" Value="14" />
@ -387,6 +387,7 @@
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" /> <Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" /> <Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" /> <Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
<Setter Property="FlyoutBackgroundColor" Value="White"/>
</Style> </Style>
<Style TargetType="NavigationPage"> <Style TargetType="NavigationPage">
@ -477,6 +478,12 @@
</VisualStateGroupList> </VisualStateGroupList>
</Setter> </Setter>
</Style> </Style>
<Style x:Key="frameObjet3" TargetType="Frame">
<Setter Property="IsClippedToBounds" Value="True"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderColor" Value="Transparent"/>
<Setter Property="CornerRadius" Value="25"/>
</Style>
<Style x:Key="frameEquip" TargetType="Frame"> <Style x:Key="frameEquip" TargetType="Frame">
<Setter Property="VisualStateManager.VisualStateGroups"> <Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList> <VisualStateGroupList>

@ -5,6 +5,7 @@ using Model.Managers;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
// Tests fonctionnels : // Tests fonctionnels :
Manager manager = new Manager(new XML_Serializer()); Manager manager = new Manager(new XML_Serializer());
@ -92,7 +93,7 @@ foreach (FruitDuDemon f in manager.FiltrerFDD("Logia"))
Console.WriteLine("\n"); Console.WriteLine("\n");
Console.WriteLine("\n"); Console.WriteLine("\n");
// Recherche dansune liste de fruit de démon pour afficher les fruits correspondant au mot clé "Nika" // Recherche dansune liste de fruit de démon pour afficher les fruits correspondant au mot clé "Nika"
foreach (FruitDuDemon f in manager.RechercheObjetOhara("Nika", new List<ObjetOhara>(manager.Fruits))) foreach (ObjetOhara f in manager.RechercheObjetOhara("Nika", new List<ObjetOhara>(manager.Fruits)) )
{ {
Console.WriteLine(f.Nom); Console.WriteLine(f.Nom);
} }
@ -106,7 +107,7 @@ foreach (Bateau b in manager.Bateaux)
// Recherche dansune liste de objet ohara pour afficher les objets ohara correspondant au mot clé "Sunny" // Recherche dansune liste de objet ohara pour afficher les objets ohara correspondant au mot clé "Sunny"
foreach (ObjetOhara o in manager.RechercheObjetOhara("Sunny", manager.GetFavoris())) foreach (ObjetOhara o in manager.RechercheObjetOhara("Sunny", manager.GetFavoris().ToList()))
{ {
Console.WriteLine(o.Nom); Console.WriteLine(o.Nom);
} }

@ -37,9 +37,36 @@ namespace TestProject1
{ {
Bateau bateau1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " "); Bateau bateau1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
Bateau bateau2 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " "); Bateau bateau2 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
Bateau? bateau3 = null;
Equipage equipage = new Equipage("Équipage du poux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
bool resultat =(bateau1.Equals(bateau2)); bool resultat =(bateau1.Equals(bateau2));
bool resultat2 =(bateau1.Equals(equipage));
bool resultat3 =(bateau1.Equals(bateau3));
Assert.True(resultat, "Les deux bateaux devraient etre égaux car ils onts le meme nom"); Assert.True(resultat, "Les deux bateaux devraient etre égaux car ils onts le meme nom");
Assert.False(resultat2);
Assert.False(resultat3);
}
[Fact]
public void GetHashCode_BateauWithSameProperties_ReturnsSameHashCode()
{
Bateau obj1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
Bateau obj2 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
var hashCode1 = obj1.GetHashCode();
var hashCode2 = obj2.GetHashCode();
Assert.True(hashCode1 == hashCode2);
}
[Fact]
public void ToString_ReturnsCorrectStringRepresentation()
{
Bateau obj1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
var result = obj1.ToString();
Assert.True("Bateau : Sunny False Sauzando Sani-go 435 321 Le Thousand Sunny est... Ce bateau a pour particularités ... " == result);
} }
} }
} }

@ -37,5 +37,25 @@ namespace TestProject1
Assert.False(resultat2); Assert.False(resultat2);
Assert.False(resultat3); Assert.False(resultat3);
} }
[Fact]
public void GetHashCode_BestiaireWithSameProperties_ReturnsSameHashCode()
{
Bestiaire obj1 = new Bestiaire("Humains", "??", "Les humains sont ...", "Ils possèdent les caractéristiques suivantes ...", "");
Bestiaire obj2 = new Bestiaire("Humains", "??", "Les humains sont ...", "Ils possèdent les caractéristiques suivantes ...", "");
var hashCode1 = obj1.GetHashCode();
var hashCode2 = obj2.GetHashCode();
Assert.True(hashCode1 == hashCode2);
}
[Fact]
public void ToString_ReturnsCorrectStringRepresentation()
{
Bestiaire obj1 = new Bestiaire("Humains", "??", "Les humains sont ...", "Ils possèdent les caractéristiques suivantes ...", "");
var result = obj1.ToString();
Assert.True("Bestiaire : Humains False ?? Les humains sont ... Ils possèdent les caractéristiques suivantes ... baseimage.png" == result);
}
} }
} }

@ -31,13 +31,78 @@ namespace TestProject1
Assert.True(resultat, "L'image devrait avoir la valeur : baseimage.png"); Assert.True(resultat, "L'image devrait avoir la valeur : baseimage.png");
} }
[Fact] [Fact]
public void ParametreCapitaine_GetSetMarcheCorrectement()
{
Equipage test = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
Personnage test2 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, 1.74, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !");
test.Capitaine=test2;
Assert.True(test.Capitaine==test2);
}
[Fact]
public void RetirerMembreViderMembre_FonctionnentCorrectement()
{
Personnage test = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, 1.74, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !");
FruitDuDemon test2 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "a", "b", "c", "d");
test.AjouterFruit(test2);
test.RetierFruit(test2);
Assert.DoesNotContain(test2, test.Fruit);
}
[Fact]
public void RetirerAllieViderAllie_FonctionnentCorrectement()
{
Equipage test = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
Equipage test2 = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
test.AjouterAllie(test2);
test.RetirerAllie(test2);
Assert.DoesNotContain(test2, test.Allie);
test.AjouterAllie(test2);
test.ViderAllie();
Assert.DoesNotContain(test2, test.Allie);
}
[Fact]
public void SurchargeEqualsEquipage_Equipage1EgaleEquipage2() public void SurchargeEqualsEquipage_Equipage1EgaleEquipage2()
{ {
Equipage equiapge1= new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", ""); Equipage equiapge1= new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
Equipage equiapge2 = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", ""); Equipage equiapge2 = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
Equipage equiapge3 = new Equipage("Équipage du poux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
Bateau bateau1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
bool resultat = (equiapge1.Equals(equiapge2)); bool resultat = (equiapge1.Equals(equiapge2));
Assert.True(resultat, "Les deux equipages devraient etre égaux car ils onts le meme nom"); bool resultat2 = (equiapge1.Equals(equiapge3));
bool resultat3 = (equiapge1.Equals(bateau1));
Assert.True(resultat, "Les deux equipages devraient etre égaux car ils ont le meme nom");
Assert.False(resultat2, "Les deux equipages ne devraient pas etre égaux car ils n'ont pas le meme nom");
Assert.False(resultat3, "Les deux equipages ne devraient pas etre égaux car ils n'ont pas le meme type");
}
[Fact]
public void GetHashCode_EquipageWithSameProperties_ReturnsSameHashCode()
{
Equipage obj1 = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
Equipage obj2 = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
var hashCode1 = obj1.GetHashCode();
var hashCode2 = obj2.GetHashCode();
Assert.True(hashCode1 == hashCode2);
}
[Fact]
public void ToString_ReturnsCorrectStringRepresentation()
{
Equipage obj1 = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
var result = obj1.ToString();
Assert.True("Equipage : Équipage du Roux False Akagami Kalzokudan East Blue 0 0 True L'équipage du Roux ... baseimage.png" == result);
} }
} }
} }

@ -13,7 +13,7 @@ namespace TestProject1
public void FDD_PremierChapEtPremierEpSuperieurOuEgalAZero_ReturnTrue() public void FDD_PremierChapEtPremierEpSuperieurOuEgalAZero_ReturnTrue()
{ {
FruitDuDemon test = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", ""); FruitDuDemon test = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "");
bool resultat = (test.Image == "baseimage.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"); Assert.True(resultat, "Les paramètre PremierChap et PremierEp doivent être supérieur ou égale à 0");
} }
[Fact] [Fact]
@ -36,9 +36,33 @@ namespace TestProject1
{ {
FruitDuDemon fruit1 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "", ""); FruitDuDemon fruit1 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "", "");
FruitDuDemon fruit2 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "", ""); FruitDuDemon fruit2 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "", "");
FruitDuDemon? fruit3 =null;
bool resultat = (fruit1.Equals(fruit2)); bool resultat = (fruit1.Equals(fruit2));
bool resultat2 = (fruit2.Equals(fruit3));
Assert.True(resultat, "Les deux fruits du démon devraient etre égaux car ils onts le meme nom"); Assert.True(resultat, "Les deux fruits du démon devraient etre égaux car ils onts le meme nom");
Assert.False(resultat2, "Les deux fruits du démon devraient etre égaux car l'un dentre eux est null");
}
[Fact]
public void GetHashCode_FruitDuDemonWithSameProperties_ReturnsSameHashCode()
{
FruitDuDemon obj1 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "", "");
FruitDuDemon obj2 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "", "");
var hashCode1 = obj1.GetHashCode();
var hashCode2 = obj2.GetHashCode();
Assert.True(hashCode1 == hashCode2);
}
[Fact]
public void ToString_ReturnsCorrectStringRepresentation()
{
FruitDuDemon obj1 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "a", "b", "c", "d");
var result = obj1.ToString();
Assert.True("FruitDuDemon : Fruit de la fumée False Moku Moku No Mi Logia 97 48 a b c d" == result);
} }
} }
} }

@ -35,8 +35,34 @@ namespace TestProject1
{ {
Ile ile1 = new Ile("Dawn", "Don-to", "East Blue", 1, 4, "L'île de Dawn est ...", "Cette île est situé dans la mer d'East Blue près de ...", ""); Ile ile1 = new Ile("Dawn", "Don-to", "East Blue", 1, 4, "L'île de Dawn est ...", "Cette île est situé dans la mer d'East Blue près de ...", "");
Ile ile2 = new Ile("Dawn", "Don-to", "East Blue", 1, 4, "L'île de Dawn est ...", "Cette île est situé dans la mer d'East Blue près de ...", ""); Ile ile2 = new Ile("Dawn", "Don-to", "East Blue", 1, 4, "L'île de Dawn est ...", "Cette île est situé dans la mer d'East Blue près de ...", "");
FruitDuDemon fruit2 = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "", "");
Ile? ile3 = null;
bool resultat = (ile1.Equals(ile2)); bool resultat = (ile1.Equals(ile2));
bool resultat2 = (ile1.Equals(ile3));
bool resultat3 = (ile1.Equals(fruit2));
Assert.True(resultat, "Les iles devraient etre égales car ils onts le meme nom"); Assert.True(resultat, "Les iles devraient etre égales car ils onts le meme nom");
Assert.False(resultat2, "Les iles devraient etre égales car l'une d'entre elle est null");
Assert.False(resultat3, "Ce test devraient etre false car il comparent une ile et un fruitdudemon");
}
[Fact]
public void GetHashCode_IleWithSameProperties_ReturnsSameHashCode()
{
Ile obj1 = new Ile("Dawn", "Don-to", "East Blue", 1, 4, "L'île de Dawn est ...", "Cette île est situé dans la mer d'East Blue près de ...", "");
Ile obj2 = new Ile("Dawn", "Don-to", "East Blue", 1, 4, "L'île de Dawn est ...", "Cette île est situé dans la mer d'East Blue près de ...", "");
var hashCode1 = obj1.GetHashCode();
var hashCode2 = obj2.GetHashCode();
Assert.True(hashCode1 == hashCode2);
}
[Fact]
public void ToString_ReturnsCorrectStringRepresentation()
{
Ile obj1 = new Ile("Dawn", "Don-to", "East Blue", 1, 4, "L'île de Dawn est ...", "Cette île est situé dans la mer d'East Blue près de ...", "");
var result = obj1.ToString();
Assert.True("Ile : Dawn Don-to East Blue 1 4 L'île de Dawn est ... Cette île est situé dans la mer d'East Blue près de ... baseimage.png" == result);
} }
} }
} }

@ -97,11 +97,11 @@ namespace TestProject1
// Act // Act
var result = manager.RechercheObjetOhara(text, liste); var result = manager.RechercheObjetOhara(text, liste);
var result2 = manager.RechercheObjetOhara("", liste);
// Assert // Assert
Assert.True(1==result.Count); Assert.True(1==result.Count);
Assert.Contains(obj1, result); Assert.Contains(obj1, result);
Assert.True(result2.Count() == liste.Count());
Assert.True(!result.Contains(obj3)); Assert.True(!result.Contains(obj3));
} }
@ -111,7 +111,7 @@ namespace TestProject1
var obj1 =manager.Fruits.First(); var obj1 =manager.Fruits.First();
var obj2 = manager.Equipages.First(); var obj2 = manager.Equipages.First();
manager.ModifierFavFDD(obj1, true); manager.ModifierFavFDD(obj1, true);
var result = manager.GetFavoris(); var result = manager.GetFavoris().ToList();
Assert.True(1==result.Count); Assert.True(1==result.Count);
Assert.Contains(obj1, result); Assert.Contains(obj1, result);
@ -347,5 +347,190 @@ namespace TestProject1
Assert.Contains(ancienBateau, manager.Bateaux); Assert.Contains(ancienBateau, manager.Bateaux);
Assert.DoesNotContain(nouveauBateau, manager.Bateaux); Assert.DoesNotContain(nouveauBateau, manager.Bateaux);
} }
[Fact]
public void TestAjouterFDD()
{
var fruit = new FruitDuDemon("Fruit de la fumée", "Moku Moku No Mi", "Logia", 97, 48, "", "", "");
manager.AjouterFDD(fruit);
Assert.Contains(fruit, manager.Fruits);
}
[Fact]
public void TestAjouterEquip()
{
var equipage = new Equipage("Equipage", "", "", 97, 48,true ,"", "");
manager.AjouterEquip(equipage);
Assert.Contains(equipage, manager.Equipages);
}
[Fact]
public void TestAjouterBest()
{
var best = new Bestiaire("Bestiaire", "", "", "");
manager.AjouterBest(best);
Assert.Contains(best, manager.Bestiaire);
}
[Fact]
public void TestAjouterPerso()
{
var perso = new Personnage("Personnage",0, "",0,0, "", "","");
manager.AjouterPerso(perso);
Assert.Contains(perso, manager.Personnages);
}
[Fact]
public void TestAjouterIle()
{
var ile = new Ile("Ile", "","", 0, 0, "", "", "");
manager.AjouterIle(ile);
Assert.Contains(ile, manager.Iles);
}
[Fact]
public void TestAjouterBateau()
{
var bateau = new Bateau("Bateau", "", 0, 0, "", "");
manager.AjouterBateau(bateau);
Assert.Contains(bateau, manager.Bateaux);
}
[Fact]
public void TestSupprimerFDD()
{
var fruit = new FruitDuDemon("Fruit", "", "Logia", 97, 48, "", "", "");
manager.AjouterFDD(fruit);
manager.SupprimerFDD(fruit);
Assert.DoesNotContain(fruit, manager.Fruits);
}
[Fact]
public void TestSupprimerEquip()
{
var equipage = new Equipage("Equipage", "", "", 97, 48, true, "", "");
manager.AjouterEquip(equipage);
manager.SupprimerEquip(equipage);
Assert.DoesNotContain(equipage, manager.Equipages);
}
[Fact]
public void TestSupprimerBest()
{
var best = new Bestiaire("Bestiaire", "", "", "");
manager.AjouterBest(best);
manager.SupprimerBest(best);
Assert.DoesNotContain(best, manager.Bestiaire);
}
[Fact]
public void TestSupprimerPerso()
{
var perso = new Personnage("Personnage", 0, "", 0, 0, "", "", "");
manager.AjouterPerso(perso);
manager.SupprimerPerso(perso);
Assert.DoesNotContain(perso, manager.Personnages);
}
[Fact]
public void TestSupprimerIle()
{
var ile = new Ile("Ile", "", "", 0, 0, "", "", "");
manager.AjouterIle(ile);
manager.SupprimerIle(ile);
Assert.DoesNotContain(ile, manager.Iles);
}
[Fact]
public void TestSupprimerBateau()
{
var bateau = new Bateau("Bateau", "", 0, 0, "", "");
manager.AjouterBateau(bateau);
manager.SupprimerBateau(bateau);
Assert.DoesNotContain(bateau, manager.Bateaux);
}
[Fact]
public void TestGetPersonnages()
{
List<Personnage> resultat = new List<Personnage>();
var result = manager.GetPersonnages();
Assert.NotNull(result);
}
[Fact]
public void TestGetFruits()
{
List<FruitDuDemon> resultat = new List<FruitDuDemon>();
var result = manager.GetFruits();
Assert.NotNull(result);
}
[Fact]
public void TestGetEquipages()
{
List<Equipage> resultat = new List<Equipage>();
var result = manager.GetEquipages();
Assert.NotNull(result);
}
[Fact]
public void TestGetBateaux()
{
List<Bateau> resultat = new List<Bateau>();
var result = manager.GetBateaux();
Assert.NotNull(result);
}
[Fact]
public void TestGetBestiaires()
{
List<Bestiaire> resultat = new List<Bestiaire>();
var result = manager.GetBestiaires();
Assert.NotNull(result);
}
[Fact]
public void TestGetIles()
{
List<Ile> resultat = new List<Ile>();
var result = manager.GetIles();
Assert.NotNull(result);
}
} }
} }

@ -36,15 +36,71 @@ namespace TestProject1
{ {
Personnage test = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png"); Personnage test = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png");
bool resultat = (test.Taille >= 0); bool resultat = (test.Taille >= 0);
Assert.True(resultat, "La taille du personnage doit avoir une valeur positive"); Assert.True(resultat, "La taille du personnage doit avoir une valeur positive");
} }
[Fact] [Fact]
public void Personnage_EquipageSetFonctionneCorrectement()
{
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");
Equipage test2 = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
test.Equipage = test2;
bool resultat = (test.Equipage == test2);
Assert.True(resultat, "La valeur Equipage du personnage devrait etre égal à test2");
}
[Fact]
public void PersonnageRetirerFruit_FonctionneCorrectement()
{
Equipage test = new Equipage("Équipage du Roux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
Personnage test2 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, 1.74, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !");
test.AjouterMembre(test2);
test.RetirerMembre(test2);
Assert.DoesNotContain(test2, test.Membre);
test.AjouterMembre(test2);
test.ViderMembre();
Assert.DoesNotContain(test2, test.Membre);
}
[Fact]
public void SurchargeEqualsPersonnage_Personnage1EgalePersonnage2() public void SurchargeEqualsPersonnage_Personnage1EgalePersonnage2()
{ {
Personnage personnage1 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png"); Personnage personnage1 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png");
Personnage personnage2 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png"); Personnage personnage2 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png");
Personnage personnage3 = new Personnage("Lufty", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png");
Bateau bateau1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
bool resultat = (personnage1.Equals(personnage1)); bool resultat = (personnage1.Equals(personnage1));
Assert.True(resultat, "Les personanges devraient etre égales car ils onts le meme nom"); bool resultat2 = (personnage1.Equals(personnage3));
bool resultat3 = (personnage1.Equals(bateau1));
Assert.True(resultat, "Les personanges devraient etre égaux car ils ont le meme nom");
Assert.False(resultat2, "Les personanges ne devraient pas etre égaux car ils n'ont pas le meme nom");
Assert.False(resultat3, "Les deux objets ne devraient pas etre égaux car ils n'ont pas le meme type");
}
[Fact]
public void GetHashCode_PersonnageWithSameProperties_ReturnsSameHashCode()
{
Personnage obj1 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png");
Personnage obj2 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png");
var hashCode1 = obj1.GetHashCode();
var hashCode2 = obj2.GetHashCode();
Assert.True(hashCode1 == hashCode2);
}
[Fact]
public void ToString_ReturnsCorrectStringRepresentation()
{
Personnage obj1 = new Personnage("Luffy", 3000000000, "Luffy au Chapeau de Paille", 19, -1, "East Blue", "Monkey D. Luffy est...", "Le Roi des Pirates, ce sera moi !", "luffy.png");
var result = obj1.ToString();
Assert.True("Personnage : Luffy False 3000000000 Luffy au Chapeau de Paille 19 East Blue Monkey D. Luffy est... Le Roi des Pirates, ce sera moi ! System.Collections.ObjectModel.ObservableCollection`1[Model.Classes.FruitDuDemon] luffy.png" == result);
} }
} }
} }

@ -1,18 +1,77 @@
using Model.Classes; using Model.Classes;
using Model.Serializer; using Model.Serializer;
using Model.Stub;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Serialization;
namespace TestProject1 namespace TestProject1
{ {
public class XMLSerializerTests public class XMLSerializerTests
{ {
public XML_Serializer serializer = new XML_Serializer(); public XML_Serializer serializer = new XML_Serializer();
private string TestFolderPath = Directory.GetCurrentDirectory();
[Fact]
public void InitialiserFichiers_FileDoesNotExist_SetPersonnageIfStubManagerReturnsNonNull()
{
// Arrange
var serializer = new XML_Serializer(TestFolderPath);
var stubManager = new StubManager();
var expectedPersonnages = stubManager.GetPersonnages();
var expectedBateaux = stubManager.GetBateaux();
var expectedFruits = stubManager.GetFruits();
var expectedBestiaires= stubManager.GetBestiaires();
var expectedEquipages=stubManager.GetEquipages();
var expectedIles = stubManager.GetIles();
// Act
serializer.InitialiserFichiers(stubManager);
// Assert
if (!File.Exists(Path.Combine(TestFolderPath, "./personnage.xml")))
{
if (expectedPersonnages != null)
{
Assert.True(expectedPersonnages.ToList()== serializer.GetPersonnages());
}
}
if (!File.Exists(Path.Combine(TestFolderPath, "./bateau.xml")))
{
if (expectedBateaux != null)
{
Assert.True(expectedBateaux.ToList() == serializer.GetBateaux());
}
}
if (!File.Exists(Path.Combine(TestFolderPath, "./fruitdudemon.xml")))
{
if (expectedFruits != null)
{
Assert.True(expectedFruits.ToList() == serializer.GetFruits());
}
}
if (!File.Exists(Path.Combine(TestFolderPath, "./equipage.xml")))
{
if (expectedEquipages != null)
{
Assert.True(expectedEquipages.ToList() == serializer.GetEquipages());
}
}
if (!File.Exists(Path.Combine(TestFolderPath, "./ile.xml")))
{
if (expectedIles != null)
{
Assert.True(expectedIles.ToList() == serializer.GetIles());
}
}
}
[Fact] [Fact]
public void SetPersonnage_SerializesAndWritesToFile() public void SetPersonnage_SerializesAndWritesToFile()
{ {

Loading…
Cancel
Save