Nicolas MAYE 2 years ago
commit e0e52c266c

@ -11,7 +11,7 @@ namespace Model
public string Nom { get; private set; } public string Nom { get; private set; }
public string UrlSite { get; private set; } public string UrlSite { get; private set; }
public string UrlLogo { get; private set; } public string UrlLogo { get; private set; }
public List<Compte> ListeDesComptes { get; private set; } public List<Compte> ListeDesComptes { get; private set; } = new List<Compte>();
public Banque(string nom, string urlSite, string urlLogo) public Banque(string nom, string urlSite, string urlLogo)
{ {
@ -28,14 +28,33 @@ namespace Model
ListeDesComptes = lescomptes; ListeDesComptes = lescomptes;
} }
private void AjouterCompte(Compte compte) public void AjouterCompte(Compte compte)
{ {
ListeDesComptes.Add(compte); ListeDesComptes.Add(compte);
} }
private void SupprimerCompte(Compte compte) public void SupprimerCompte(Compte compte)
{ {
ListeDesComptes.Remove(compte); ListeDesComptes.Remove(compte);
} }
public bool ExisteCompte(string s)
{
foreach (Compte compte in ListeDesComptes)
{
if (compte.Nom.Equals(s))
return true;
}
return false;
}
public Compte ReturnCompte(string s)
{
foreach (Compte compte in ListeDesComptes)
{
if (compte.Nom.Equals(s))
return compte;
}
throw new KeyNotFoundException();
}
} }
} }

@ -1,54 +1,54 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
//using Banque; //using Banque;
namespace Model namespace Model
{ {
public class Inscrit public class Inscrit
{ {
public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal) public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal)
{ {
Id = id; Id = id;
Nom = nom; Nom = nom;
Mail = mail; Mail = mail;
Prenom = prenom; Prenom = prenom;
Mdp = mdp; Mdp = mdp;
SoldeTotal = soldeTotal; SoldeTotal = soldeTotal;
} }
public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal,List<Banque>lesbanques) public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal,List<Banque>lesbanques)
{ {
Id = id; Id = id;
Nom = nom; Nom = nom;
Mail = mail; Mail = mail;
Prenom = prenom; Prenom = prenom;
Mdp = mdp; Mdp = mdp;
SoldeTotal = soldeTotal; SoldeTotal = soldeTotal;
LesBanques = lesbanques; LesBanques = lesbanques;
} }
public string Id { get; private set; } public string Id { get; private set; }
public string Nom { get; private set; } public string Nom { get; private set; }
public string Mail { get; private set; } public string Mail { get; private set; }
public string Prenom { get; private set; } public string Prenom { get; private set; }
public string Mdp { get; private set; } public string Mdp { get; private set; }
public double SoldeTotal { get; private set; } public double SoldeTotal { get; private set; }
public Devises Dev { get; private set; } public Devises Dev { get; private set; }
private List<Banque> LesBanques { get; set; } private List<Banque> LesBanques { get; set; }
/*public void ajouterBanque(Banque b) /*public void ajouterBanque(Banque b)
{ {
TouteLesBanques.Add(b); TouteLesBanques.Add(b);
} }
public void ajouterBanque(Banque b) public void ajouterBanque(Banque b)
{ {
TouteLesBanques.Remove(b); TouteLesBanques.Remove(b);
}*/ }*/
public void ChoisirDevise(Devises devise) public void ChoisirDevise(Devises devise)
{ {
Dev = devise; Dev = devise;
} }
} }
} }

@ -11,6 +11,8 @@ namespace Model
public List<Banque> Banques = new(); public List<Banque> Banques = new();
public List<Inscrit> Inscrits = new(); public List<Inscrit> Inscrits = new();
public List<Compte> Comptes = new(); public List<Compte> Comptes = new();
// ajouter load all pour tout les inscrits
public List<Inscrit> LoadInscrit() public List<Inscrit> LoadInscrit()
{ {
Inscrits.Add(new("00001", "Evard", "lucasevard@gmail.com","Lucas","test",10,LoadBanques())); Inscrits.Add(new("00001", "Evard", "lucasevard@gmail.com","Lucas","test",10,LoadBanques()));

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
namespace TestsUnitaires
{
public class TestUnitBanque
{
Banque test = new("BNP Paribas", "https://mabanque.bnpparibas/", "https://logos-marques.com/wp-content/uploads/2020/12/BNP-Paribas-logo.png");
Banque test2 = new("BNP Paribas", "https://mabanque.bnpparibas/", "https://logos-marques.com/wp-content/uploads/2020/12/BNP-Paribas-logo.png", listeCompte);
[Fact]
public void testConstructeur1()
{
Assert.NotNull(test);
Assert.Equal("BNP Paribas", test.Nom);
Assert.NotEqual("https://mabanque.bnpparibas/", test.Nom);
Assert.Equal("https://mabanque.bnpparibas/", test.UrlSite);
Assert.Equal("https://logos-marques.com/wp-content/uploads/2020/12/BNP-Paribas-logo.png", test.UrlLogo);
}
[Fact]
public void testConstructeur2()
{
List<Compte> listeCompte = new();
Compte tc = new("Livret A", 16956);
listeCompte.Add(tc);
Assert.NotNull(test2);
Assert.NotNull(test2.ListeDesComptes);
Assert.Equal("BNP Paribas", test.Nom);
Assert.NotEqual("https://mabanque.bnpparibas/", test2.Nom);
Assert.Equal("https://mabanque.bnpparibas/", test2.UrlSite);
Assert.Equal("https://logos-marques.com/wp-content/uploads/2020/12/BNP-Paribas-logo.png", test2.UrlLogo);
Assert.Contains(tc, test2.ListeDesComptes);
}
[Fact]
public void testAjouterCompte()
{
Compte tc = new("Livret A", 16956);
Assert.NotNull(test.ListeDesComptes);
test.AjouterCompte(tc);
Assert.Contains(tc, test.ListeDesComptes);
}
[Fact]
public void testSupprimerCompte()
{
Compte tc = new("Livret A", 16956);
Assert.NotNull(test.ListeDesComptes);
test.AjouterCompte(tc);
Assert.Contains(tc, test.ListeDesComptes);
test.SupprimerCompte(tc);
Assert.DoesNotContain(tc, test.ListeDesComptes);
}
}
}
Loading…
Cancel
Save