You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.1 KiB
66 lines
2.1 KiB
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<Item>(), its.LesItems);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestConstructeur1()
|
|
{
|
|
IList<Item> l = stb.ChargerLesDonnées()["Langages"] as IList<Item>;
|
|
Items its = new Items(l);
|
|
Assert.Equal(l.OrderBy(lang => (lang as Langage).Nom).ToList(), its.LesItems);
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public void TestSuppression()
|
|
{
|
|
IList<Item> l = stb.ChargerLesDonnées()["Comtpes"] as IList<Item>;
|
|
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<ArgumentException>(() => its.Supprimer(c1));
|
|
Assert.DoesNotContain(c1, its.LesItems);
|
|
Assert.DoesNotContain(c2, its.LesItems);
|
|
Assert.Null(gestionaireDeTest.ItemsComptes.ItemCourant);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestAjout()
|
|
{
|
|
IList<Item> l = stb.ChargerLesDonnées()["Comptes"] as IList<Item>;
|
|
Compte c = new Compte("c", "c");
|
|
Items its = new Items(l);
|
|
its.Ajouter(c);
|
|
Assert.Contains(c, its.LesItems);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestExists()
|
|
{
|
|
IList<Item> l = stb.ChargerLesDonnées()["Comptes"] as IList<Item>;
|
|
Items its = new Items(l);
|
|
Assert.True(its.Exists(new Compte("id10", "mdp1")));
|
|
Assert.False(its.Exists(new Compte("zzzzzz", "mezezezf")));
|
|
}
|
|
}
|
|
}
|