Ajout test unitaire de banque,modification de la classe banque et ajout de méthode dans banque

Code
Lucas EVARD 2 years ago
parent dc5993dbb0
commit 35a3e81c20

@ -5,11 +5,14 @@ VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IHM", "IHM\IHM.csproj", "{355FC972-9C0D-4CBD-8003-EFBDACA7CFFF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{ACFA83F8-98C8-43AE-9328-B3F751098FFA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{ACFA83F8-98C8-43AE-9328-B3F751098FFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestFonctionnel", "TestFonctionnel\TestFonctionnel.csproj", "{7AC4F84F-1124-4EC1-BF38-17F3F4FBEB3E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFonctionnel", "TestFonctionnel\TestFonctionnel.csproj", "{7AC4F84F-1124-4EC1-BF38-17F3F4FBEB3E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestsUnitaires", "TestsUnitaires\TestsUnitaires.csproj", "{B1AE713C-B5DE-4E81-A33F-818AAD0548A7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestsUnitaires", "TestsUnitaires\TestsUnitaires.csproj", "{B1AE713C-B5DE-4E81-A33F-818AAD0548A7}"
ProjectSection(ProjectDependencies) = postProject
{ACFA83F8-98C8-43AE-9328-B3F751098FFA} = {ACFA83F8-98C8-43AE-9328-B3F751098FFA}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -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<Compte> ListeDesComptes { get; private set; }
public List<Compte> ListeDesComptes { get; private set; } = new List<Compte>();
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();
}
}
}

@ -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,List<Banque>lesbanques)
{
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<Banque> 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,List<Banque>lesbanques)
{
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<Banque> 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;
}
}
}

@ -11,6 +11,8 @@ namespace Model
public List<Banque> Banques = new();
public List<Inscrit> Inscrits = new();
public List<Compte> Comptes = new();
// ajouter load all pour tout les inscrits
public List<Inscrit> LoadInscrit()
{
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);
}
}
}

@ -21,4 +21,8 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

Loading…
Cancel
Save