From 294bf73d9e0ac2079402c3146ab2574167d0f54a Mon Sep 17 00:00:00 2001 From: luevard Date: Wed, 4 Jan 2023 20:25:12 +0100 Subject: [PATCH] Test unitaire Compte --- Sources/Modele/Compte.cs | 21 +++++++++-- Sources/TestsUnitaires/TestUnitCompte.cs | 48 +++++++++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/Sources/Modele/Compte.cs b/Sources/Modele/Compte.cs index 4282bc4..f56c0ee 100644 --- a/Sources/Modele/Compte.cs +++ b/Sources/Modele/Compte.cs @@ -33,16 +33,31 @@ namespace Model Solde = solde; DerniereModification = DateTime.Now; } - public Compte(string id, string nom, double solde, List lesOpe) : base() + public Compte(string id, string nom, double solde, List lesOpe) { + Identifiant = id; + Nom = nom; + Solde = solde; + DerniereModification = DateTime.Now; LesOpe = lesOpe; } - public Compte(string id, string nom, double solde, List lesOpe, List lesPla) : base() + public Compte(string id, string nom, double solde, List lesOpe, List lesPla) { + Identifiant = id; + Nom = nom; + Solde = solde; + DerniereModification = DateTime.Now; LesPla = lesPla; + LesOpe = lesOpe; } - public Compte(string id, string nom, double solde, List lesOpe, List lesPla, List lesEch) : base() + public Compte(string id, string nom, double solde, List lesOpe, List lesPla, List lesEch) { + Identifiant = id; + Nom = nom; + Solde = solde; + DerniereModification = DateTime.Now; + LesPla = lesPla; + LesOpe = lesOpe; LesEch = lesEch; } diff --git a/Sources/TestsUnitaires/TestUnitCompte.cs b/Sources/TestsUnitaires/TestUnitCompte.cs index dc4d0af..a9cd587 100644 --- a/Sources/TestsUnitaires/TestUnitCompte.cs +++ b/Sources/TestsUnitaires/TestUnitCompte.cs @@ -21,17 +21,63 @@ namespace TestsUnitaires Assert.Equal(1245.34, c2.Solde); } + [Fact] + public void TestConstructeurCompte2() + { + List testlistope = new(); + Operation testope = new("test", 20, DateTime.Now, MethodePayement.Cb); + testlistope.Add(testope); + Compte c1 = new("012345678901", "Livret A", 234,testlistope); + Compte c2 = new("012345678902", "&e23R_te7", 1245.34, testlistope); + Assert.Equal("Livret A", c1.Nom); + Assert.Equal("&e23R_te7", c2.Nom); + Assert.Equal(234, c1.Solde); + Assert.Equal(1245.34, c2.Solde); + Assert.NotNull(testlistope); + Assert.NotNull(testope); + Assert.True(c1.LesOpe.Count() == 1); + Assert.True(c2.LesOpe.Count() == 1); + c1.supprimerOperation(testope); + c2.supprimerOperation(testope); + Assert.True(c1.LesOpe.Count() == 0); + Assert.True(c2.LesOpe.Count() == 0); + } + + + [Fact] + public void testAjouterOperation() + { + Compte c1 = new("012345678901", "Livret A", 234); + c1.ajouterOperation(new("test", 20, DateTime.Now, MethodePayement.Cb)); + Assert.True(c1.LesOpe.Count() == 1); + } + + [Fact] + public void testSupprimerOperation() + { + Compte c1 = new("012345678901", "Livret A", 234); + Operation testope = new("test", 20, DateTime.Now, MethodePayement.Cb); + c1.ajouterOperation(testope); + Assert.True(c1.LesOpe.Count() == 1); + c1.supprimerOperation(testope); + Assert.True(c1.LesOpe.Count() == 0); + } + + [Fact] public void testSupprimerBanque() { Banque bq = new Banque("Crédit Agricole", "https://creditagricole.fr", "https://yt3.ggpht.com/a/AGF-l7_mEfX2eQaGm8GefLOg5ZMRciNw-pESE3gUWg=s900-c-k-c0xffffffff-no-rj-mo"); Inscrit i1 = new Inscrit("A1001", "Smith", "smith@gmail.com", "luke", "test20000aA", 500); - //Assert.NotNull(i1.LesBanques); + Assert.NotNull(i1.LesBanques); i1.ajouterBanque(bq); Assert.Contains(bq, i1.LesBanques); i1.SupprimerBanque(bq); Assert.DoesNotContain(bq, i1.LesBanques); } + + + } }