|
|
|
@ -11,8 +11,14 @@ using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace UnitTesting
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Classe test pour la classe Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ManageurUT
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test le constructeur de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestConstruteur()
|
|
|
|
|
{
|
|
|
|
@ -27,8 +33,11 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(manageur.PartiesNonTerminees);
|
|
|
|
|
Assert.NotEmpty(manageur.Joueurs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test la méthode Sauvegarder d'une partie.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestSauvegarder()
|
|
|
|
|
{
|
|
|
|
@ -38,8 +47,11 @@ namespace UnitTesting
|
|
|
|
|
MethodInfo? infosMethode = typeof(Manageur).GetMethod("Sauvegarder", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(infosMethode);
|
|
|
|
|
infosMethode.Invoke(manageur, []);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test la méthode ChargerPartie qui charge une partie.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestChargerPartie()
|
|
|
|
|
{
|
|
|
|
@ -55,8 +67,11 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
Assert.Contains(nouvellePartie, manageur.Parties);
|
|
|
|
|
Assert.Contains(nouvellePartie, manageur.PartiesNonTerminees);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test la méthode NouvellePartie de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestNouvellePartie()
|
|
|
|
|
{
|
|
|
|
@ -67,8 +82,11 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
Assert.Contains(nouvellePartie, manageur.Parties);
|
|
|
|
|
Assert.Contains(nouvellePartie, manageur.PartiesNonTerminees);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Premier test de la méthode EcouterPartie de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEcouterPartie()
|
|
|
|
|
{
|
|
|
|
@ -154,8 +172,11 @@ namespace UnitTesting
|
|
|
|
|
Assert.NotEmpty(PartieDemanderJoueurJouer.GetInvocationList());
|
|
|
|
|
Assert.NotEmpty(PartiePasserLaMain.GetInvocationList());
|
|
|
|
|
Assert.NotEmpty(PartiePartieTerminee.GetInvocationList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Deuxième test de la méthode EcouterPartie de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEcouterPartie2()
|
|
|
|
|
{
|
|
|
|
@ -203,8 +224,11 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(1, celeste.Statistique(new ReglesClassiques(), Statistique.PartieGagnee));
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartieEgalite));
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartiePerdue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Troisième test de la méthode EcouterPartie de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEcouterPartie3()
|
|
|
|
|
{
|
|
|
|
@ -252,8 +276,11 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartieGagnee));
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartieEgalite));
|
|
|
|
|
Assert.Equal(1, celeste.Statistique(new ReglesClassiques(), Statistique.PartiePerdue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Quatrième test de la méthode EcouterPartie de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEcouterPartie4()
|
|
|
|
|
{
|
|
|
|
@ -301,8 +328,11 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartieGagnee));
|
|
|
|
|
Assert.Equal(1, celeste.Statistique(new ReglesClassiques(), Statistique.PartieEgalite));
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartiePerdue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Cinquième test de la méthode EcouterPartie de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestEcouterPartie5()
|
|
|
|
|
{
|
|
|
|
@ -350,8 +380,11 @@ namespace UnitTesting
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartieGagnee));
|
|
|
|
|
Assert.Equal(0, celeste.Statistique(new ReglesClassiques(), Statistique.PartieEgalite));
|
|
|
|
|
Assert.Equal(1, celeste.Statistique(new ReglesClassiques(), Statistique.PartiePerdue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test de la méthode DemanderJoueurExistant de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestDemanderJoueurExistant()
|
|
|
|
|
{
|
|
|
|
@ -367,8 +400,11 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
object? toto = infosMethode.Invoke(manageur, ["Toto"]);
|
|
|
|
|
Assert.Null(toto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test de la méthode DemanderJoueur de Manageur.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestDemanderJoueur()
|
|
|
|
|
{
|
|
|
|
|