|
|
|
@ -9,6 +9,8 @@ using CoreLibrary.Joueurs;
|
|
|
|
|
using CoreLibrary.Regles;
|
|
|
|
|
using CoreLibrary.Evenements;
|
|
|
|
|
using CoreLibrary.Exceptions;
|
|
|
|
|
using System.Diagnostics.Tracing;
|
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace UnitTesting
|
|
|
|
@ -262,7 +264,8 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
bool appelee = false;
|
|
|
|
|
|
|
|
|
|
partie.PartieDemanderJoueur += (sender, e) => {
|
|
|
|
|
partie.PartieDemanderJoueur += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
appelee = true;
|
|
|
|
|
|
|
|
|
|
if (e.Indice == 1)
|
|
|
|
@ -284,7 +287,8 @@ namespace UnitTesting
|
|
|
|
|
|
|
|
|
|
bool appelee = false;
|
|
|
|
|
|
|
|
|
|
partie.PartieDemanderJoueur += (sender, e) => {
|
|
|
|
|
partie.PartieDemanderJoueur += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
appelee = true;
|
|
|
|
|
|
|
|
|
|
Assert.Throws<NomJoueurInterditException>(() => e.JoueurDemande.SeConnecter(new Joueur("Robot")));
|
|
|
|
@ -304,7 +308,8 @@ namespace UnitTesting
|
|
|
|
|
Assert.NotNull(partie.Robots);
|
|
|
|
|
Assert.Empty(partie.Robots);
|
|
|
|
|
|
|
|
|
|
partie.PartieDemanderJoueur += (sender, e) => {
|
|
|
|
|
partie.PartieDemanderJoueur += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
e.JoueurDemande.SeConnecter(new Robot());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -536,5 +541,74 @@ namespace UnitTesting
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestPartieEcoute()
|
|
|
|
|
{
|
|
|
|
|
Partie partie = new Partie(new ReglesClassiques());
|
|
|
|
|
|
|
|
|
|
FieldInfo? joueursInfo = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
FieldInfo? plateauxInfo = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(joueursInfo);
|
|
|
|
|
Assert.NotNull(plateauxInfo);
|
|
|
|
|
|
|
|
|
|
Dictionary<string, bool>? joueurs = joueursInfo.GetValue(partie) as Dictionary<string, bool>;
|
|
|
|
|
List<Plateau>? plateaux = plateauxInfo.GetValue(partie) as List<Plateau>;
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(joueurs);
|
|
|
|
|
Assert.NotNull(plateaux);
|
|
|
|
|
|
|
|
|
|
joueurs.Add("Céleste", true);
|
|
|
|
|
plateaux.Add(new Plateau(4, 12));
|
|
|
|
|
|
|
|
|
|
MethodInfo? QuandPartieDemanderJoueurInfo = typeof(Partie).GetMethod("QuandPartieDemanderJoueur", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
MethodInfo? QuandPartieDebutPartieInfo = typeof(Partie).GetMethod("QuandPartieDebutPartie", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
MethodInfo? QuandPartieDemanderJoueurJouerInfo = typeof(Partie).GetMethod("QuandPartieDemanderJoueurJouer", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
MethodInfo? QuandPartieNouveauTourInfo = typeof(Partie).GetMethod("QuandPartieNouveauTour", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
MethodInfo? QuandPartiePasserLaMainInfo = typeof(Partie).GetMethod("QuandPartiePasserLaMain", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
MethodInfo? QuandPartiePartieTermineeInfo = typeof(Partie).GetMethod("QuandPartiePartieTerminee", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(QuandPartieDemanderJoueurInfo);
|
|
|
|
|
Assert.NotNull(QuandPartieDebutPartieInfo);
|
|
|
|
|
Assert.NotNull(QuandPartieDemanderJoueurJouerInfo);
|
|
|
|
|
Assert.NotNull(QuandPartieNouveauTourInfo);
|
|
|
|
|
Assert.NotNull(QuandPartiePasserLaMainInfo);
|
|
|
|
|
Assert.NotNull(QuandPartiePartieTermineeInfo);
|
|
|
|
|
|
|
|
|
|
QuandPartieDemanderJoueurInfo?.Invoke(partie, [new Joueur()]);
|
|
|
|
|
QuandPartieDebutPartieInfo?.Invoke(partie, []);
|
|
|
|
|
QuandPartieDemanderJoueurJouerInfo?.Invoke(partie, [new Code(4)]);
|
|
|
|
|
QuandPartieNouveauTourInfo?.Invoke(partie, [new Code(4)]);
|
|
|
|
|
QuandPartiePasserLaMainInfo?.Invoke(partie, []);
|
|
|
|
|
QuandPartiePartieTermineeInfo?.Invoke(partie, [new List<string>(["Céleste"]), new List<string>(["Robot 1"])]);
|
|
|
|
|
|
|
|
|
|
bool appel1 = false;
|
|
|
|
|
partie.PartieDemanderJoueur += (sender, e) => appel1 = true;
|
|
|
|
|
bool appel2 = false;
|
|
|
|
|
partie.PartieDebutPartie += (sender, e) => appel2 = true;
|
|
|
|
|
bool appel3 = false;
|
|
|
|
|
partie.PartieDemanderJoueurJouer += (sender, e) => appel3 = true;
|
|
|
|
|
bool appel4 = false;
|
|
|
|
|
partie.PartieNouveauTour += (sender, e) => appel4 = true;
|
|
|
|
|
bool appel5 = false;
|
|
|
|
|
partie.PartiePasserLaMain += (sender, e) => appel5 = true;
|
|
|
|
|
bool appel6 = false;
|
|
|
|
|
partie.PartiePartieTerminee += (sender, e) => appel6 = true;
|
|
|
|
|
|
|
|
|
|
QuandPartieDemanderJoueurInfo?.Invoke(partie, [new Joueur()]);
|
|
|
|
|
QuandPartieDebutPartieInfo?.Invoke(partie, []);
|
|
|
|
|
QuandPartieDemanderJoueurJouerInfo?.Invoke(partie, [new Code(4)]);
|
|
|
|
|
QuandPartieNouveauTourInfo?.Invoke(partie, [new Code(4)]);
|
|
|
|
|
QuandPartiePasserLaMainInfo?.Invoke(partie, []);
|
|
|
|
|
QuandPartiePartieTermineeInfo?.Invoke(partie, [new List<string>(["Céleste"]), new List<string>(["Robot 1"])]);
|
|
|
|
|
|
|
|
|
|
Assert.True(appel1);
|
|
|
|
|
Assert.True(appel2);
|
|
|
|
|
Assert.True(appel3);
|
|
|
|
|
Assert.True(appel4);
|
|
|
|
|
Assert.True(appel5);
|
|
|
|
|
Assert.True(appel6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|