diff --git a/Code/Model/Banque.cs b/Code/Model/Banque.cs index 07b43ae..2cb64f1 100644 --- a/Code/Model/Banque.cs +++ b/Code/Model/Banque.cs @@ -11,7 +11,7 @@ namespace Model public string Nom { get; private set; } public string UrlSite { get; private set; } public string UrlLogo { get; private set; } - public List ListeDesComptes { get; private set; } + public List ListeDesComptes { get; private set; } = new List(); public Banque(string nom, string urlSite, string urlLogo) { @@ -28,14 +28,33 @@ namespace Model ListeDesComptes = lescomptes; } - private void AjouterCompte(Compte compte) + public void AjouterCompte(Compte compte) { ListeDesComptes.Add(compte); } - private void SupprimerCompte(Compte compte) + public void SupprimerCompte(Compte 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(); + } } } diff --git a/Code/Model/Inscrit.cs b/Code/Model/Inscrit.cs index e6e362c..771f949 100644 --- a/Code/Model/Inscrit.cs +++ b/Code/Model/Inscrit.cs @@ -1,54 +1,54 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -//using Banque; - -namespace Model -{ - public class Inscrit - { - public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal) - { - Id = id; - Nom = nom; - Mail = mail; - Prenom = prenom; - Mdp = mdp; - SoldeTotal = soldeTotal; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +//using Banque; + +namespace Model +{ + public class Inscrit + { + public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal) + { + Id = id; + Nom = nom; + Mail = mail; + Prenom = prenom; + Mdp = mdp; + SoldeTotal = soldeTotal; } - public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal,Listlesbanques) - { - Id = id; - Nom = nom; - Mail = mail; - Prenom = prenom; - Mdp = mdp; - SoldeTotal = soldeTotal; - LesBanques = lesbanques; - } - public string Id { get; private set; } - public string Nom { get; private set; } - public string Mail { get; private set; } - public string Prenom { get; private set; } - public string Mdp { get; private set; } - public double SoldeTotal { get; private set; } - public Devises Dev { get; private set; } - private List LesBanques { get; set; } - - /*public void ajouterBanque(Banque b) - { - TouteLesBanques.Add(b); - } - public void ajouterBanque(Banque b) - { - TouteLesBanques.Remove(b); - }*/ - public void ChoisirDevise(Devises devise) - { - Dev = devise; - } - - } -} + public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal,Listlesbanques) + { + Id = id; + Nom = nom; + Mail = mail; + Prenom = prenom; + Mdp = mdp; + SoldeTotal = soldeTotal; + LesBanques = lesbanques; + } + public string Id { get; private set; } + public string Nom { get; private set; } + public string Mail { get; private set; } + public string Prenom { get; private set; } + public string Mdp { get; private set; } + public double SoldeTotal { get; private set; } + public Devises Dev { get; private set; } + private List LesBanques { get; set; } + + /*public void ajouterBanque(Banque b) + { + TouteLesBanques.Add(b); + } + public void ajouterBanque(Banque b) + { + TouteLesBanques.Remove(b); + }*/ + public void ChoisirDevise(Devises devise) + { + Dev = devise; + } + + } +} diff --git a/Code/Model/Stub.cs b/Code/Model/Stub.cs index 1799fc8..67fbc68 100644 --- a/Code/Model/Stub.cs +++ b/Code/Model/Stub.cs @@ -11,6 +11,8 @@ namespace Model public List Banques = new(); public List Inscrits = new(); public List Comptes = new(); + + // ajouter load all pour tout les inscrits public List LoadInscrit() { Inscrits.Add(new("00001", "Evard", "lucasevard@gmail.com","Lucas","test",10,LoadBanques())); diff --git a/Code/TestsUnitaires/TestUnitBanque.cs b/Code/TestsUnitaires/TestUnitBanque.cs new file mode 100644 index 0000000..b2d4b5c --- /dev/null +++ b/Code/TestsUnitaires/TestUnitBanque.cs @@ -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 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); + } + + } +} \ No newline at end of file