using données; using notre_bibliotheque; using System; using System.Collections.Generic; using System.Linq; using Xunit; namespace tests_unitaires { public class ItemsUnitTest { private IPercistance stb = new Stub(""); [Fact] public void TestConstructeur0() { Items its = new Items(); Assert.Equal(new List(), its.LesItems); } [Fact] public void TestConstructeur1() { IList l = stb.ChargerLesDonnées()["Langages"] as IList; Items its = new Items(l); Assert.Equal(l.OrderBy(lang => (lang as Langage).Nom).ToList(), its.LesItems); } [Fact] public void TestSuppression() { IList l = stb.ChargerLesDonnées()["Comtpes"] as IList; Items its = new Items(l); Gestionaire.Percistance = new Stub(""); GestionaireDeComptes gestionaireDeTest = new GestionaireDeComptes(its); Compte c1 = new Compte("id2", "mdp1"); Compte c2 = new Compte("id3", "mdp1"); gestionaireDeTest.ItemsComptes.Supprimer(c1); gestionaireDeTest.ItemsComptes.Supprimer(c2); Assert.Throws(() => its.Supprimer(c1)); Assert.DoesNotContain(c1, its.LesItems); Assert.DoesNotContain(c2, its.LesItems); Assert.Null(gestionaireDeTest.ItemsComptes.ItemCourant); } [Fact] public void TestAjout() { IList l = stb.ChargerLesDonnées()["Comptes"] as IList; Compte c = new Compte("c", "c"); Items its = new Items(l); its.Ajouter(c); Assert.Contains(c, its.LesItems); } [Fact] public void TestExists() { IList l = stb.ChargerLesDonnées()["Comptes"] as IList; Items its = new Items(l); Assert.True(its.Exists(new Compte("id10", "mdp1"))); Assert.False(its.Exists(new Compte("zzzzzz", "mezezezf"))); } } }