Possiblité de créer et de modifer les parametres affiliation (Bateau), Capitaine,Membre et Allie (Equipage); Fruits (Personnage) + Tests unitaires
continuous-integration/drone/push Build is passing Details

pull/15/head
Yoan 2 years ago
parent 12afbc962d
commit fb8b0927e2

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
@ -81,12 +82,46 @@ namespace Model.Classes
} }
} }
[DataMember(Name = "capitaine")] [DataMember(Name = "capitaine")]
public Personnage? Capitaine { get; set; } private Personnage? capitaine;
public Personnage? Capitaine {
get=>capitaine;
set
{
capitaine = value;
OnPropertyChanged();
}
}
[DataMember(Name = "membre")] [DataMember(Name = "membre")]
public List<Personnage> Membre { get; set; } = new List<Personnage>(); private ObservableCollection<Personnage> membre = new ObservableCollection<Personnage>();
public IReadOnlyCollection<Personnage> Membre { get=>membre; }
public void AjouterMembre(Personnage? p)
{
if(p!=null) membre.Add(p);
}
public void RetirerMembre(Personnage? p)
{
if(p!=null) membre.Remove(p);
}
public void ViderMembre() => membre.Clear();
[DataMember(Name = "allie")] [DataMember(Name = "allie")]
public List<Equipage> Allie { get; set; } = new List<Equipage>(); private ObservableCollection<Equipage> allie = new ObservableCollection<Equipage>();
public IReadOnlyCollection<Equipage> Allie { get => allie; }
public void AjouterAllie(Equipage? p)
{
if (p != null) allie.Add(p);
}
public void RetirerAllie(Equipage? p)
{
if (p != null) allie.Remove(p);
}
public void ViderAllie() => allie.Clear();
public Equipage(string nom, string nomRomanise, string region, int premierChap, int premierEp, bool statut, string description) : base(nom) public Equipage(string nom, string nomRomanise, string region, int premierChap, int premierEp, bool statut, string description) : base(nom)
{ {

@ -20,12 +20,7 @@ namespace Model.Classes
public string? Nom { public string? Nom {
get => nom; get => nom;
set set
{ {
if (nom == value)
{
return;
}
nom = value; nom = value;
OnPropertyChanged(); OnPropertyChanged();
} }
@ -36,10 +31,7 @@ namespace Model.Classes
public string? Image { public string? Image {
get => image; get => image;
set set
{ {
if (image == value)
return;
image = value; image = value;
OnPropertyChanged(); OnPropertyChanged();
@ -51,9 +43,7 @@ namespace Model.Classes
public bool EstFavori { public bool EstFavori {
get=>estfavori; get=>estfavori;
set set
{ {
if (estfavori == value)
return;
estfavori = value; estfavori = value;
} }
} }
@ -92,7 +82,7 @@ namespace Model.Classes
} }
public override string ToString() public override string ToString()
{ {
return "ObjetOhara :" + Nom + " " +EstFavori+ " " + Image; return "ObjetOhara : " + Nom + " " +EstFavori+ " " + Image;
} }
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)

@ -1,4 +1,5 @@
using System.ComponentModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -120,9 +121,22 @@ namespace Model.Classes
} }
} }
[DataMember(Name = "fruit", EmitDefaultValue = false)] [DataMember(Name = "fruit", EmitDefaultValue = false)]
public List<FruitDuDemon> Fruit { get; set; } = new List<FruitDuDemon>(); private ObservableCollection<FruitDuDemon> fruit = new ObservableCollection<FruitDuDemon>();
public IReadOnlyCollection<FruitDuDemon> Fruit {
get=>fruit;
}
public void AjouterFruit(FruitDuDemon? f)
{
if (f == null) return;
fruit.Add(f);
}
public void RetierFruit(FruitDuDemon? f)
{
if (f == null) return;
fruit.Remove(f);
}
public void ViderFruit() => fruit.Clear();
public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation) : base(nom) public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation) : base(nom)

@ -18,7 +18,7 @@ namespace Model.Stub
var clown = new Equipage("Équipage du Clown", "Bagï Kalzokudan", "East Blue", 8, 4, true, "L'équipage du Clown ...", "clown.png"); var clown = new Equipage("Équipage du Clown", "Bagï Kalzokudan", "East Blue", 8, 4, true, "L'équipage du Clown ...", "clown.png");
var blanche = new Equipage("Équipage de Barbe Blanche", "Shirohige Kaizokudan", "East Blue", 234, 151, true, "L'équipage de Barbe Blanche ...", "blanche.jpg"); var blanche = new Equipage("Équipage de Barbe Blanche", "Shirohige Kaizokudan", "East Blue", 234, 151, true, "L'équipage de Barbe Blanche ...", "blanche.jpg");
var noire = new Equipage("Équipage de Barbe Noire", "Kurohige Kaizokudan", "East Blue", 234, 151, true, "L'équipage de Barbe Noire ...", "noire.png"); var noire = new Equipage("Équipage de Barbe Noire", "Kurohige Kaizokudan", "East Blue", 234, 151, true, "L'équipage de Barbe Noire ...", "noire.png");
paille.Allie.Add(clown); paille.AjouterAllie(clown);
paille = RemplirEquipage(paille, persos, new List<string> { "Luffy" }); paille = RemplirEquipage(paille, persos, new List<string> { "Luffy" });
Equipages = new List<Equipage>() Equipages = new List<Equipage>()
{ {
@ -26,9 +26,7 @@ namespace Model.Stub
roux, roux,
clown, clown,
blanche, blanche,
};
};
} }
public IEnumerable<Equipage> RecupererEquipage() public IEnumerable<Equipage> RecupererEquipage()
{ {
@ -38,10 +36,10 @@ namespace Model.Stub
public Equipage RemplirEquipage(Equipage equipage,List<Personnage> persos,List<string> noms) public Equipage RemplirEquipage(Equipage equipage,List<Personnage> persos,List<string> noms)
{ {
var persos2 = persos.Where(p => noms.Contains(p.Nom)); var persos2 = persos.Where(p => noms.Contains(p.Nom));
equipage.Membre.AddRange(persos2); foreach (Personnage p in persos2)
equipage.AjouterMembre(p);
return equipage; return equipage;
} }
} }
} }

@ -60,32 +60,32 @@ namespace Model.Stub
public void SetBateau(List<Bateau> listeBateaux) public void SetBateau(List<Bateau> listeBateaux)
{ {
throw new NotImplementedException(); return;
} }
public void SetBestiaire(List<Bestiaire> listeBest) public void SetBestiaire(List<Bestiaire> listeBest)
{ {
throw new NotImplementedException(); return;
} }
public void SetEquipage(List<Equipage> listeEquip) public void SetEquipage(List<Equipage> listeEquip)
{ {
throw new NotImplementedException(); return;
} }
public void SetFDD(List<FruitDuDemon> listeFDD) public void SetFDD(List<FruitDuDemon> listeFDD)
{ {
throw new NotImplementedException(); return;
} }
public void SetIle(List<Ile> listeIle) public void SetIle(List<Ile> listeIle)
{ {
throw new NotImplementedException(); return;
} }
public void SetPersonnage(List<Personnage> listePerso) public void SetPersonnage(List<Personnage> listePerso)
{ {
throw new NotImplementedException(); return;
} }
} }
} }

@ -26,8 +26,8 @@ namespace Model.Stub
List<FruitDuDemon> fruits = new List<FruitDuDemon>(stubFruitDuDemon.RecupererFruit()); List<FruitDuDemon> fruits = new List<FruitDuDemon>(stubFruitDuDemon.RecupererFruit());
luffy.Fruit.AddRange(fruits.Where(p => p.Nom == "Fruit de l'humain modèle Nika")); luffy.AjouterFruit(fruits.FirstOrDefault(p => p.Nom == "Fruit de l'humain modèle Nika"));
robin.Fruit.AddRange(fruits.Where(p => p.Nom == "Fruit des Éclosions")); robin.AjouterFruit(fruits.FirstOrDefault(p => p.Nom == "Fruit des Éclosions"));
List<Personnage> persos = new List<Personnage>() List<Personnage> persos = new List<Personnage>()

@ -49,6 +49,55 @@
<Button Text="Annuler" Style="{StaticResource buttonRetirerFavInfo}" Clicked="ButtonAnnuler_Clicked" /> <Button Text="Annuler" Style="{StaticResource buttonRetirerFavInfo}" Clicked="ButtonAnnuler_Clicked" />
</VerticalStackLayout > </VerticalStackLayout >
<VerticalStackLayout Spacing="5" Margin="2"> <VerticalStackLayout Spacing="5" Margin="2">
<Frame Style="{StaticResource frameModif}" HeightRequest="175">
<HorizontalStackLayout HorizontalOptions="CenterAndExpand">
<CollectionView x:Name="listeCapitaine" SelectionChanged="AjoutCapitaine" SelectionMode="Single" HorizontalOptions="CenterAndExpand">
<CollectionView.Header>
<Label Text="Capitaine :"/>
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<Label Text="{Binding Nom}"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</HorizontalStackLayout>
</Frame>
<Frame x:Name="framePicker" Style="{StaticResource frameModif}" HeightRequest="250">
<HorizontalStackLayout HorizontalOptions="Center">
<ScrollView Orientation="Vertical">
<CollectionView x:Name="listeAllie" ItemsSource="{Binding Equipages}" SelectionChanged="AjoutAllie" SelectionMode="Multiple">
<CollectionView.Header>
<Label Text="Allié(s) :"/>
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<Label Text="{Binding Nom}"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
<ScrollView Orientation="Vertical">
<CollectionView x:Name="listeMembre" ItemsSource="{Binding Personnages}" SelectionChanged="AjoutMembre" SelectionMode="Multiple">
<CollectionView.Header>
<Label Text="Membre(s) :"/>
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<Label Text="{Binding Nom}"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
</HorizontalStackLayout>
</Frame>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Statut :" FontAttributes="Bold"/> <Label Text="Statut :" FontAttributes="Bold"/>

@ -1,5 +1,6 @@
using Model.Classes; using Model.Classes;
using Model.Managers; using Model.Managers;
using System.Collections.Generic;
namespace Ohara; namespace Ohara;
@ -21,6 +22,8 @@ public partial class ModalEquipage : ContentPage
} }
InitializeComponent(); InitializeComponent();
BindingContext = nouvelEquipage; BindingContext = nouvelEquipage;
framePicker.BindingContext = manager;
listeCapitaine.ItemsSource = manager.Personnages;
} }
private async void ButtonConfirmer_Clicked(object sender, EventArgs e) private async void ButtonConfirmer_Clicked(object sender, EventArgs e)
@ -54,4 +57,26 @@ public partial class ModalEquipage : ContentPage
nouvelEquipage.Image = stream; nouvelEquipage.Image = stream;
} }
} }
private void AjoutAllie(object sender, SelectionChangedEventArgs e)
{
if (nouvelEquipage.Allie != null)
nouvelEquipage.ViderAllie();
foreach (var equipage in listeAllie.SelectedItems)
{
nouvelEquipage.AjouterAllie(equipage as Equipage);
}
}
private void AjoutMembre(object sender, SelectionChangedEventArgs e)
{
if (nouvelEquipage.Membre != null)
nouvelEquipage.ViderMembre();
foreach (var perso in listeMembre.SelectedItems)
{
nouvelEquipage.AjouterMembre(perso as Personnage);
}
}
private void AjoutCapitaine(object sender, SelectionChangedEventArgs e)
{
nouvelEquipage.Capitaine = listeCapitaine.SelectedItem as Personnage;
}
} }

@ -41,16 +41,48 @@
<Entry Text="{Binding Taille}" /> <Entry Text="{Binding Taille}" />
</HorizontalStackLayout> </HorizontalStackLayout>
</Frame> </Frame>
<Button Text="Annuler" Style="{StaticResource buttonRetirerFavInfo}" Clicked="ButtonAnnuler_Clicked" />
</VerticalStackLayout >
<VerticalStackLayout Spacing="5" Margin="2">
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Origine :" FontAttributes="Bold"/> <Label Text="Origine :" FontAttributes="Bold"/>
<Entry Text="{Binding Origine}" /> <Entry Text="{Binding Origine}" />
</HorizontalStackLayout > </HorizontalStackLayout >
</Frame> </Frame>
<Button Text="Annuler" Style="{StaticResource buttonRetirerFavInfo}" Clicked="ButtonAnnuler_Clicked" />
</VerticalStackLayout >
<VerticalStackLayout Spacing="5" Margin="2">
<Frame x:Name="framePicker" Style="{StaticResource frameModif}" HeightRequest="300">
<HorizontalStackLayout HorizontalOptions="Center">
<ScrollView Orientation="Vertical">
<CollectionView x:Name="listeEquipages" ItemsSource="{Binding Equipages}" SelectionChanged="AjoutEquipage" SelectionMode="Single">
<CollectionView.Header>
<Label Text="Equipage :"/>
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<Label Text="{Binding Nom}"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
<ScrollView Orientation="Vertical">
<CollectionView x:Name="listeFruits" ItemsSource="{Binding Fruits}" SelectionChanged="AjoutFruit" SelectionMode="Multiple">
<CollectionView.Header>
<Label Text="Fruit(s) du démon :"/>
</CollectionView.Header>
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<Label Text="{Binding Nom}"/>
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ScrollView>
</HorizontalStackLayout>
</Frame>
<Frame Style="{StaticResource frameModif}"> <Frame Style="{StaticResource frameModif}">
<HorizontalStackLayout HorizontalOptions="Center"> <HorizontalStackLayout HorizontalOptions="Center">
<Label Text="Biographie :" FontAttributes="Bold"/> <Label Text="Biographie :" FontAttributes="Bold"/>

@ -21,6 +21,7 @@ public partial class ModalPersonnage : ContentPage
} }
InitializeComponent(); InitializeComponent();
BindingContext = nouveauPerso; BindingContext = nouveauPerso;
framePicker.BindingContext = manager;
} }
private async void ButtonConfirmer_Clicked(object sender, EventArgs e) private async void ButtonConfirmer_Clicked(object sender, EventArgs e)
@ -29,6 +30,7 @@ public partial class ModalPersonnage : ContentPage
{ {
manager.ModifierPerso(nouveauPerso, ancienNom); manager.ModifierPerso(nouveauPerso, ancienNom);
nouveauPerso = manager.SelectedItem as Personnage; nouveauPerso = manager.SelectedItem as Personnage;
} }
else else
{ {
@ -55,4 +57,18 @@ public partial class ModalPersonnage : ContentPage
nouveauPerso.Image = stream; nouveauPerso.Image = stream;
} }
} }
private void AjoutEquipage(object sender, SelectionChangedEventArgs e)
{
nouveauPerso.Equipage = listeEquipages.SelectedItem as Equipage;
}
private void AjoutFruit(object sender, SelectionChangedEventArgs e)
{
if (nouveauPerso.Fruit != null)
nouveauPerso.ViderFruit();
foreach(var fruit in listeFruits.SelectedItems)
{
nouveauPerso.AjouterFruit(fruit as FruitDuDemon);
}
}
} }

@ -19,10 +19,7 @@ public partial class PageInfoBateau : ContentPage
retirerFav.IsVisible = true; retirerFav.IsVisible = true;
} }
if(((Bateau)manager.SelectedItem).Affiliation==null)
bouttonAffiliation.IsVisible=false;
BindingContext =manager.SelectedItem; BindingContext =manager.SelectedItem;
} }
private void AjouterFav_Clicked(object sender, EventArgs e) private void AjouterFav_Clicked(object sender, EventArgs e)

@ -68,25 +68,25 @@
</StackLayout> </StackLayout>
</Frame> </Frame>
</VerticalStackLayout> </VerticalStackLayout>
</Grid> </Grid>
<Label Text="Description :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/> <Label Text="Description :" 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" />
<Label Text="{Binding Description}" TextColor="#72a3b3" /> <Label Text="{Binding Description}" TextColor="#72a3b3" />
<Label Text="Membre(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/> <Grid ColumnDefinitions="75*,25*" ColumnSpacing="10">
<Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" /> <VerticalStackLayout Spacing="5">
<CollectionView x:Name="listMembre" ItemsLayout="HorizontalList" ItemsSource="{Binding Membre}" SelectionMode="Single" SelectionChanged="listMembre_SelectionChanged" > <Label Text="Membre(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/>
<CollectionView.ItemTemplate> <Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" />
<DataTemplate> <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.ItemTemplate>
<DataTemplate>
<Frame Style="{StaticResource frameObjet}" Margin="5"> <Frame Style="{StaticResource frameObjet}" Margin="5">
<StackLayout Orientation="Vertical"> <StackLayout Orientation="Vertical">
<Image Source="{Binding Image}" <Image Source="{Binding Image}"
HeightRequest="175" HeightRequest="175"
WidthRequest="175"/> WidthRequest="175"/>
<Label <Label
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Start" VerticalOptions="Start"
HorizontalTextAlignment="Center" HorizontalTextAlignment="Center"
@ -95,40 +95,66 @@
FontSize="15" FontSize="15"
TextColor="#72a3b3" TextColor="#72a3b3"
FontAttributes="Bold" /> FontAttributes="Bold" />
</StackLayout> </StackLayout>
</Frame> </Frame>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>
<Label Text="Allié(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/> </ScrollView>
<Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" /> </VerticalStackLayout>
<CollectionView x:Name="listAlle" ItemsLayout="HorizontalList" ItemsSource="{Binding Allie}" SelectionMode="Single" SelectionChanged="listAlle_SelectionChanged" > <VerticalStackLayout Grid.Column="1" Spacing="5">
<CollectionView.ItemTemplate> <Label Text="Capitaine :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/>
<DataTemplate> <Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" />
<Frame Style="{StaticResource frameEquip}" > <Frame BindingContext="{Binding Capitaine}" Style="{StaticResource frameObjet}" HorizontalOptions="Center" Margin="5">
<StackLayout Orientation="Vertical"> <Frame.GestureRecognizers>
<Image Source="{Binding Image}" <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</Frame.GestureRecognizers>
<StackLayout Orientation="Vertical">
<Image Source="{Binding Image}"
HeightRequest="175" HeightRequest="175"
WidthRequest="175"/> WidthRequest="175"/>
<Label <Label
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Start" VerticalOptions="Start"
HorizontalTextAlignment="Center" HorizontalTextAlignment="Center"
Text="{Binding Nom}" Text="{Binding Nom}"
FontSize="15" FontSize="15"
TextColor="White" TextColor="#72a3b3"
FontAttributes="Bold" /> FontAttributes="Bold" />
</StackLayout>
</Frame>
</VerticalStackLayout>
</Grid>
<Label Text="Allié(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/>
<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.ItemTemplate>
<DataTemplate>
<Frame Style="{StaticResource frameEquip}" Margin="5">
<StackLayout Orientation="Vertical">
<Image Source="{Binding Image}"
HeightRequest="175"
WidthRequest="175"/>
<Label
HorizontalOptions="Center"
VerticalOptions="Start"
HorizontalTextAlignment="Center"
Text="{Binding Nom}"
FontSize="15"
TextColor="White"
FontAttributes="Bold" />
</StackLayout> </StackLayout>
</Frame> </Frame>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>
</VerticalStackLayout> </VerticalStackLayout>
</ScrollView> </ScrollView>
</ContentPage> </ContentPage>

@ -16,10 +16,8 @@ public partial class PageInfoEquipage : ContentPage
bouttonFav.IsEnabled = false; bouttonFav.IsEnabled = false;
bouttonFav.Text = "Ajouté au favoris"; bouttonFav.Text = "Ajouté au favoris";
retirerFav.IsVisible = true; retirerFav.IsVisible = true;
}
}
BindingContext = manager.SelectedItem; BindingContext = manager.SelectedItem;
} }
private void AjouterFav_Clicked(object sender, EventArgs e) private void AjouterFav_Clicked(object sender, EventArgs e)
@ -37,8 +35,6 @@ public partial class PageInfoEquipage : ContentPage
bouttonFav.Text = "Ajouter au favoris"; bouttonFav.Text = "Ajouter au favoris";
retirerFav.IsVisible = false; retirerFav.IsVisible = false;
} }
private async void listMembre_SelectionChanged(object sender, SelectionChangedEventArgs e) private async void listMembre_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (e.CurrentSelection.Count == 0) return; if (e.CurrentSelection.Count == 0) return;
@ -52,7 +48,7 @@ public partial class PageInfoEquipage : ContentPage
manager.SelectedItem = (Equipage)listAlle.SelectedItem; manager.SelectedItem = (Equipage)listAlle.SelectedItem;
await Navigation.PushAsync(new PageInfoEquipage()); await Navigation.PushAsync(new PageInfoEquipage());
} }
private async void Supprimer_Clicked(object sender, EventArgs e) private async void Supprimer_Clicked(object sender, EventArgs e)
{ {
manager.SupprimerEquip((Equipage)manager.SelectedItem); manager.SupprimerEquip((Equipage)manager.SelectedItem);
@ -60,12 +56,18 @@ public partial class PageInfoEquipage : ContentPage
} }
private void ContentPage_Appearing(object sender, EventArgs e) private void ContentPage_Appearing(object sender, EventArgs e)
{ {
listAlle.SelectedItem=null; listAlle.SelectedItem=null;
listMembre.SelectedItem=null; listMembre.SelectedItem=null;
} }
private async void Modifier_Clicked(object sender, EventArgs e) private async void Modifier_Clicked(object sender, EventArgs e)
{ {
await Shell.Current.GoToAsync(nameof(ModalEquipage), true); await Shell.Current.GoToAsync(nameof(ModalEquipage), true);
} }
private async void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
{
manager.SelectedItem = manager.SelectedItem as Personnage;
await Shell.Current.GoToAsync(nameof(PageInfoPersonnage));
}
} }

@ -22,10 +22,7 @@
<Label Text="2 - Citation" TextColor="#72a3b3"/> <Label Text="2 - Citation" TextColor="#72a3b3"/>
</Frame> </Frame>
<Frame Style="{StaticResource frameInfo}"> <Frame Style="{StaticResource frameInfo}">
<Label Text="3 - Equipage(s)" TextColor="#72a3b3"/> <Label Text="3 - Fruit(s)" TextColor="#72a3b3"/>
</Frame>
<Frame Style="{StaticResource frameInfo}">
<Label Text="4 - Fruit(s)" TextColor="#72a3b3"/>
</Frame> </Frame>
<FlexLayout AlignItems="Start" Wrap="NoWrap" Direction="Row" JustifyContent="SpaceEvenly" HorizontalOptions="Start"> <FlexLayout AlignItems="Start" Wrap="NoWrap" Direction="Row" JustifyContent="SpaceEvenly" HorizontalOptions="Start">
<Button Text="Supprimer" Style="{StaticResource buttonRetirerFavInfo}" Clicked="Supprimer_Clicked" FlexLayout.Basis="49.5%"/> <Button Text="Supprimer" Style="{StaticResource buttonRetirerFavInfo}" Clicked="Supprimer_Clicked" FlexLayout.Basis="49.5%"/>
@ -43,7 +40,6 @@
IsClippedToBounds="True" IsClippedToBounds="True"
Padding="0" Padding="0"
HeightRequest="400" HeightRequest="400"
> >
<Image <Image
Source="{Binding Image}" Source="{Binding Image}"
@ -51,7 +47,9 @@
/> />
</Frame> </Frame>
<VerticalStackLayout Spacing="4"> <VerticalStackLayout Spacing="4">
<Button x:Name="bouttonAffiliation" Text="{Binding Equipage.Nom, StringFormat='Equipage : {0}'}" Style="{StaticResource buttonFavsInfo}" Clicked="ButtonAffiliation_Clicked" ToolTipProperties.Text="Clickez pour en savoir plus..." FontSize="15"/>
<Frame Style="{StaticResource frameInfo}"> <Frame Style="{StaticResource frameInfo}">
<StackLayout HorizontalOptions="Center" Orientation="Horizontal" Spacing="5"> <StackLayout HorizontalOptions="Center" Orientation="Horizontal" Spacing="5">
<Label Text="Prime :" TextColor="#72a3b3" FontAttributes="Bold"/> <Label Text="Prime :" TextColor="#72a3b3" FontAttributes="Bold"/>
@ -95,35 +93,12 @@
<Label Text="Citation(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/> <Label Text="Citation(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" />
<Label Text="{Binding Citation}" Style="{StaticResource citationPerso}" /> <Label Text="{Binding Citation}" Style="{StaticResource citationPerso}" />
<Label Text="Equipage(s) :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/>
<Line X1="0" Y1="0" X2="3000" Y2="0" StrokeThickness="2" Stroke="#72a3b3" />
<CollectionView x:Name="listEquip" ItemsLayout="HorizontalList" ItemsSource="{Binding Equipage}" SelectionMode="Single" SelectionChanged="listEquip_SelectionChanged">
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame Style="{StaticResource frameEquip}" Margin="5">
<StackLayout Orientation="Vertical">
<Image Source="{Binding Image}"
HeightRequest="175"
WidthRequest="175"/>
<Label
HorizontalOptions="Center"
VerticalOptions="Start"
HorizontalTextAlignment="Center"
Text="{Binding Nom}"
FontSize="15"
TextColor="white"
FontAttributes="Bold" />
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Label Text="Fruit :" TextColor="#72a3b3" FontSize="20" FontAttributes="Bold"/> <Label Text="Fruit :" 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="listFruit" ItemsLayout="HorizontalList" ItemsSource="{Binding Fruit}" SelectionMode="Single" SelectionChanged="listFruit_SelectionChanged"> <CollectionView x:Name="listFruit" ItemsLayout="HorizontalList" ItemsSource="{Binding Fruit}" SelectionMode="Single" SelectionChanged="listFruit_SelectionChanged">
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Frame Style="{StaticResource frameEquip}" Margin="5"> <Frame Style="{StaticResource frameObjet}" Margin="5">
<StackLayout Orientation="Vertical"> <StackLayout Orientation="Vertical">
<Image Source="{Binding Image}" <Image Source="{Binding Image}"
HeightRequest="175" HeightRequest="175"
@ -134,7 +109,7 @@
HorizontalTextAlignment="Center" HorizontalTextAlignment="Center"
Text="{Binding Nom}" Text="{Binding Nom}"
FontSize="15" FontSize="15"
TextColor="white" TextColor="#72a3b3"
FontAttributes="Bold" /> FontAttributes="Bold" />
</StackLayout> </StackLayout>
</Frame> </Frame>

@ -17,8 +17,11 @@ public partial class PageInfoPersonnage : ContentPage
retirerFav.IsVisible = true; retirerFav.IsVisible = true;
} }
if (((Personnage)manager.SelectedItem).Equipage == null)
bouttonAffiliation.IsVisible = false;
BindingContext = manager.SelectedItem; BindingContext = manager.SelectedItem;
} }
private void AjouterFav_Clicked(object sender, EventArgs e) private void AjouterFav_Clicked(object sender, EventArgs e)
@ -37,14 +40,6 @@ public partial class PageInfoPersonnage : ContentPage
retirerFav.IsVisible = false; retirerFav.IsVisible = false;
} }
private async void listEquip_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.CurrentSelection.Count == 0) return;
manager.SelectedItem = (Equipage)listEquip.SelectedItem;
await Navigation.PushAsync(new PageInfoEquipage());
}
private async void listFruit_SelectionChanged(object sender, SelectionChangedEventArgs e) private async void listFruit_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
@ -54,9 +49,7 @@ public partial class PageInfoPersonnage : ContentPage
} }
private void ContentPage_Appearing(object sender, EventArgs e) private void ContentPage_Appearing(object sender, EventArgs e)
{ {
listEquip.SelectedItem = null;
listFruit.SelectedItem = null; listFruit.SelectedItem = null;
} }
private async void Supprimer_Clicked(object sender, EventArgs e) private async void Supprimer_Clicked(object sender, EventArgs e)
@ -69,4 +62,12 @@ public partial class PageInfoPersonnage : ContentPage
{ {
await Shell.Current.GoToAsync(nameof(ModalPersonnage), true); await Shell.Current.GoToAsync(nameof(ModalPersonnage), true);
} }
private async void ButtonAffiliation_Clicked(object sender, EventArgs e)
{
manager.SelectedItem = (manager.SelectedItem as Personnage).Equipage;
await Navigation.PushAsync(new PageInfoEquipage());
}
} }

@ -50,7 +50,6 @@ namespace TestProject1
Assert.NotNull(paille); Assert.NotNull(paille);
Assert.True(paille.Membre != null); Assert.True(paille.Membre != null);
Assert.True(1 == paille.Membre.Count); Assert.True(1 == paille.Membre.Count);
Assert.True("Luffy" == paille.Membre[0].Nom);
} }
[Fact] [Fact]
@ -91,8 +90,7 @@ namespace TestProject1
Assert.NotNull(result); Assert.NotNull(result);
Assert.True(result.Membre != null); Assert.True(result.Membre != null);
Assert.True(2 == result.Membre.Count); Assert.True(2 == result.Membre.Count);
Assert.True("Luffy" == result.Membre[0].Nom);
Assert.True("Zoro"== result.Membre[1].Nom);
} }
} }
} }

@ -0,0 +1,121 @@
using Model.Classes;
using Model.Managers;
using Model.Serializer;
using Model.Stub;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestProject1
{
public class TestManager
{
public Manager manager = new Manager(new StubManager());
[Fact]
public void Constructor_InitializesCollections()
{
Assert.NotNull(manager.Bateaux);
Assert.NotNull(manager.Personnages);
Assert.NotNull(manager.Fruits);
Assert.NotNull(manager.Iles);
Assert.NotNull(manager.Bestiaire);
Assert.NotNull(manager.Equipages);
}
[Fact]
public void FiltrerFDD_ReturnsFilteredFruits()
{
// Arrange
var type = "Paramecia";
var fruits = new List<FruitDuDemon>
{
new FruitDuDemon("fruit1", "", "Paramecia", 0, 0,"","",""),
new FruitDuDemon("fruit2", "", "Logia", 0, 0,"","",""),
new FruitDuDemon("fruit3", "", "Zoan", 0, 0,"","",""),
};
manager.Fruits = new ObservableCollection<FruitDuDemon>(fruits);
// Act
var result = manager.FiltrerFDD(type);
// Assert
Assert.True(1== result.Count);
Assert.True("Paramecia"== result[0].Type);
}
[Fact]
public void FiltrerBateau_ReturnsMatchingBateaux()
{
var bateau1 = new Bateau("bateau1", "", 0, 0, "", "");
var bateau2 = new Bateau("bateau1", "", 0, 0, "", "");
var bateau3 = new Bateau("bateau", "", 0, 0, "", "");
bateau1.Affiliation = new Equipage("Mugiwara", "","",0,0,true,"");
bateau2.Affiliation = new Equipage("Barbe noire", "", "", 0, 0, true, "");
bateau3.Affiliation = new Equipage("Barbe blanche", "", "", 0, 0, true, "");
var bateaux = new List<Bateau> { bateau1,bateau2 ,bateau3};
manager.Bateaux = new ObservableCollection<Bateau>(bateaux);
var result = manager.FiltrerBateau("Mugiwara");
Assert.True(1 == result.Count);
Assert.True("Mugiwara" == result[0].Affiliation.Nom);
}
[Fact]
public void FiltrerIle_ReturnsMatchingIles()
{
var iles = new List<Ile> {
new Ile("ile1","","East Blue",0,0,"",""),
new Ile("ile2","","Grand Line",0,0,"",""),
new Ile("ile3","","West Blue",0,0,"",""),
};
manager.Iles = new ObservableCollection<Ile>(iles);
var result = manager.FiltrerIle("East Blue");
Assert.True(1 == result.Count);
Assert.True("East Blue" == result[0].Region);
}
[Fact]
public void RechercheObjetOhara_ReturnsFilteredList()
{
// Arrange
var text = "abc";
var obj1 = new ObjetOhara("abcd");
var obj2 = new ObjetOhara("bcde");
var obj3 = new ObjetOhara("defg");
var liste = new List<ObjetOhara> { obj1, obj2, obj3 };
// Act
var result = manager.RechercheObjetOhara(text, liste);
// Assert
Assert.True(1==result.Count);
Assert.Contains(obj1, result);
Assert.True(!result.Contains(obj3));
}
[Fact]
public void GetFavoris_ReturnsFavoritedObjects()
{
var obj1 =manager.Fruits.First();
var obj2 = manager.Equipages.First();
manager.ModifierFavFDD(obj1, true);
var result = manager.GetFavoris();
Assert.True(1==result.Count);
Assert.Contains(obj1, result);
Assert.False(result.Contains(obj2));
}
}
}

@ -0,0 +1,53 @@
using Model.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestProject1
{
public class TestObjetOhara
{
[Fact]
public void ToString_ReturnsCorrectStringRepresentation()
{
// Arrange
var obj = new ObjetOhara("Objet 1", "image.png", true);
// Act
var result = obj.ToString();
// Assert
Assert.True("ObjetOhara : Objet 1 True image.png"== result);
}
[Fact]
public void Equals_SameObject_ReturnsTrue()
{
// Arrange
var obj = new ObjetOhara("Objet 1");
// Act
var result = obj.Equals(obj);
// Assert
Assert.True(result);
}
[Fact]
public void GetHashCode_ObjectsWithSameProperties_ReturnsSameHashCode()
{
// Arrange
var obj1 = new ObjetOhara("Objet 1", "image.png", true);
var obj2 = new ObjetOhara("Objet 1", "image.png", true);
// Act
var hashCode1 = obj1.GetHashCode();
var hashCode2 = obj2.GetHashCode();
// Assert
Assert.True(hashCode1==hashCode2);
}
}
}

@ -0,0 +1,75 @@
using Model.Classes;
using Model.Serializer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace TestProject1
{
public class XMLSerializerTests
{
public XML_Serializer serializer = new XML_Serializer();
[Fact]
public void SetPersonnage_SerializesAndWritesToFile()
{
/// Arrange
var obj1 = new Personnage("Personnage 1", 0, "", 0, 0, "", "", "");
var obj2 = new Personnage("Personnage 2", 0, "", 0, 0, "", "", "");
var listePerso = new List<Personnage>
{
obj1,
obj2,
};
// Act
serializer.SetPersonnage(listePerso);
// Assert
string xmlFilePath = Path.Combine(serializer.Chemin, "personnage.xml");
Assert.True(File.Exists(xmlFilePath));
using (Stream stream = File.OpenRead(xmlFilePath))
{
var deserializer = new DataContractSerializer(typeof(List<Personnage>));
var result = deserializer.ReadObject(stream) as List<Personnage>;
Assert.NotNull(result);
Assert.Contains(obj1,result);
Assert.Contains(obj2,result);
}
}
[Fact]
public void GetPersonnages_ReadsFromFileAndDeserializes()
{
// Arrange
var obj1 = new Personnage("Personnage 1", 0, "", 0, 0, "", "", "");
var obj2 = new Personnage("Personnage 2", 0, "", 0, 0, "", "", "");
var listePerso = new List<Personnage>
{
obj1,
obj2,
};
string xmlFilePath = Path.Combine(serializer.Chemin, "personnage.xml");
using (Stream stream = File.Create(xmlFilePath))
{
var xmlSerializer = new DataContractSerializer(typeof(List<Personnage>));
xmlSerializer.WriteObject(stream, listePerso);
}
// Act
var result = serializer.GetPersonnages();
// Assert
Assert.NotNull(result);
var resultList = result.ToList();
Assert.Contains(obj1, result);
Assert.Contains(obj2, result);
}
}
}
Loading…
Cancel
Save