|
|
|
@ -1,27 +1,40 @@
|
|
|
|
|
// Cas 3 - Plateau rempli, code mauvaise couleur
|
|
|
|
|
using CoreLibrary.Core;
|
|
|
|
|
using CoreLibrary.Core;
|
|
|
|
|
using CoreLibrary.Joueurs;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
Code code3 = new Code(1);
|
|
|
|
|
code3.AjouterJeton(new Jeton(Couleur.Rouge));
|
|
|
|
|
Code codeSecret = new Code(1);
|
|
|
|
|
codeSecret.AjouterJeton(new Jeton(Couleur.Rouge));
|
|
|
|
|
|
|
|
|
|
Plateau plateau3;
|
|
|
|
|
Code? codeSecret3;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
plateau3 = new Plateau(1, 1);
|
|
|
|
|
Code code1 = new Code(1);
|
|
|
|
|
code1.AjouterJeton(new Jeton(Couleur.Vert));
|
|
|
|
|
|
|
|
|
|
FieldInfo? codeSecretInfo3 = typeof(Plateau).GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Code code2 = new Code(1);
|
|
|
|
|
code2.AjouterJeton(new Jeton(Couleur.Jaune));
|
|
|
|
|
|
|
|
|
|
codeSecret3 = codeSecretInfo3.GetValue(plateau2) as Code;
|
|
|
|
|
Assert.NotNull(codeSecret3);
|
|
|
|
|
} while (codeSecret3.RecupererJeton(0).Equals(code3.RecupererJeton(0)));
|
|
|
|
|
List<Code> codes = new List<Code>([
|
|
|
|
|
codeSecret,
|
|
|
|
|
code1,
|
|
|
|
|
code2,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
plateau3.AjouterCode(codeSecret3);
|
|
|
|
|
Plateau plateau = new Plateau(1, 1);
|
|
|
|
|
|
|
|
|
|
MethodInfo? EstCodePossible3 = typeof(Robot).GetMethod("EstCodePossible", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
|
|
|
|
|
Assert.NotNull(EstCodePossible3);
|
|
|
|
|
object? estPossibleObj3 = EstCodePossible3.Invoke(new Robot(), [plateau3, code3]);
|
|
|
|
|
Assert.NotNull(estPossibleObj3);
|
|
|
|
|
Assert.IsType<bool>(estPossibleObj3);
|
|
|
|
|
Assert.False((bool)estPossibleObj3);
|
|
|
|
|
FieldInfo? codeSecretInfo = typeof(Plateau).GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
|
|
|
|
|
codeSecretInfo.SetValue(plateau, codeSecret);
|
|
|
|
|
|
|
|
|
|
codeSecretInfo = typeof(Plateau).GetField("codeSecret", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
|
|
|
|
|
plateau.AjouterCode(codeSecret);
|
|
|
|
|
var a = codeSecretInfo.GetValue(plateau);
|
|
|
|
|
var b = plateau.Grille;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MethodInfo? SupprimerCodesImpossiblesInfo = typeof(Robot).GetMethod("SupprimerCodesImpossibles", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
|
|
|
|
|
|
|
|
|
|
SupprimerCodesImpossiblesInfo.Invoke(new Robot(), [codes, plateau]);
|
|
|
|
|
|
|
|
|
|
Console.ReadLine();
|