test victoire partie
continuous-integration/drone/push Build is passing Details

master
Céleste BARBOSA 11 months ago
parent 14ec0fef3b
commit 34b5b90c68

@ -609,5 +609,364 @@ namespace UnitTesting
Assert.True(appel5);
Assert.True(appel6);
}
[Fact]
public void TestPartiePlateauAjouterCode()
{
// Cas 1 : dernier joueur - false, plateau complet - false, victoire - false
Partie partie1 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo1 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo1 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo1 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo1);
Assert.NotNull(plateauxInfo1);
Assert.NotNull(courantInfo1);
Dictionary<string, bool>? joueurs1 = joueursInfo1.GetValue(partie1) as Dictionary<string, bool>;
List<Plateau>? plateaux1 = plateauxInfo1.GetValue(partie1) as List<Plateau>;
Assert.NotNull(joueurs1);
Assert.NotNull(plateaux1);
courantInfo1.SetValue(partie1, 0);
joueurs1.Add("Céleste", true);
joueurs1.Add("Pauline", true);
Plateau plateau1_j1 = new Plateau(1, 1);
Plateau plateau1_j2 = new Plateau(1, 1);
plateaux1.Add(plateau1_j1);
plateaux1.Add(plateau1_j2);
PropertyInfo? VictoireInfo1_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo1_j1);
VictoireInfo1_j1.SetValue(plateau1_j1, false);
PropertyInfo? VictoireInfo1_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo1_j2);
VictoireInfo1_j2.SetValue(plateau1_j2, false);
MethodInfo? PlateauAjouterCodeInfo1 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo1);
PlateauAjouterCodeInfo1.Invoke(partie1, [null, new PlateauAjouterCodeEventArgs(plateau1_j1)]);
// Cas 2 : dernier joueur - false, plateau complet - false, victoire - true
Partie partie2 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo2 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo2 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo2 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo2);
Assert.NotNull(plateauxInfo2);
Assert.NotNull(courantInfo2);
Dictionary<string, bool>? joueurs2 = joueursInfo2.GetValue(partie2) as Dictionary<string, bool>;
List<Plateau>? plateaux2 = plateauxInfo2.GetValue(partie2) as List<Plateau>;
Assert.NotNull(joueurs2);
Assert.NotNull(plateaux2);
courantInfo2.SetValue(partie2, 0);
joueurs2.Add("Céleste", true);
joueurs2.Add("Pauline", true);
Plateau plateau2_j1 = new Plateau(1, 1);
Plateau plateau2_j2= new Plateau(1, 1);
plateaux2.Add(plateau2_j1);
plateaux2.Add(plateau2_j2);
PropertyInfo? VictoireInfo2_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo2_j1);
VictoireInfo2_j1.SetValue(plateau2_j1, true);
PropertyInfo? VictoireInfo2_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo2_j2);
VictoireInfo2_j2.SetValue(plateau2_j2, true);
MethodInfo? PlateauAjouterCodeInfo2 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo2);
PlateauAjouterCodeInfo2.Invoke(partie2, [null, new PlateauAjouterCodeEventArgs(plateau2_j1)]);
// Cas 3 : dernier joueur - false, plateau complet - true, victoire - false
Partie partie3 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo3 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo3 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo3 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo3);
Assert.NotNull(plateauxInfo3);
Assert.NotNull(courantInfo3);
Dictionary<string, bool>? joueurs3 = joueursInfo3.GetValue(partie3) as Dictionary<string, bool>;
List<Plateau>? plateaux3 = plateauxInfo3.GetValue(partie3) as List<Plateau>;
Assert.NotNull(joueurs3);
Assert.NotNull(plateaux3);
courantInfo3.SetValue(partie3, 0);
joueurs3.Add("Céleste", true);
joueurs3.Add("Pauline", true);
Plateau plateau3_j1 = new Plateau(1, 1);
Plateau plateau3_j2 = new Plateau(1, 1);
Code code3_j1 = new Code(1);
code3_j1.AjouterJeton(new Jeton(Couleur.Rouge));
Code code3_j2 = new Code(1);
code3_j2.AjouterJeton(new Jeton(Couleur.Rouge));
plateau3_j1.AjouterCode(code3_j1);
plateau3_j2.AjouterCode(code3_j2);
plateaux3.Add(plateau3_j1);
plateaux3.Add(plateau3_j2);
PropertyInfo? VictoireInfo3_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo3_j1);
VictoireInfo3_j1.SetValue(plateau3_j1, false);
PropertyInfo? VictoireInfo3_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo3_j2);
VictoireInfo3_j2.SetValue(plateau3_j2, false);
MethodInfo? PlateauAjouterCodeInfo3 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo3);
PlateauAjouterCodeInfo3.Invoke(partie3, [null, new PlateauAjouterCodeEventArgs(plateau3_j1)]);
// Cas 4 : dernier joueur - false, plateau complet - true, victoire - true
Partie partie4 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo4 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo4 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo4 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo4);
Assert.NotNull(plateauxInfo4);
Assert.NotNull(courantInfo4);
Dictionary<string, bool>? joueurs4 = joueursInfo4.GetValue(partie4) as Dictionary<string, bool>;
List<Plateau>? plateaux4 = plateauxInfo4.GetValue(partie4) as List<Plateau>;
Assert.NotNull(joueurs4);
Assert.NotNull(plateaux4);
courantInfo4.SetValue(partie4, 0);
joueurs4.Add("Céleste", true);
joueurs4.Add("Pauline", true);
Plateau plateau4_j1 = new Plateau(1, 1);
Plateau plateau4_j2 = new Plateau(1, 1);
Code code4_j1 = new Code(1);
code4_j1.AjouterJeton(new Jeton(Couleur.Rouge));
Code code4_j2 = new Code(1);
code4_j2.AjouterJeton(new Jeton(Couleur.Rouge));
plateau4_j1.AjouterCode(code4_j1);
plateau4_j2.AjouterCode(code4_j2);
plateaux4.Add(plateau4_j1);
plateaux4.Add(plateau4_j2);
PropertyInfo? VictoireInfo4_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo4_j1);
VictoireInfo4_j1.SetValue(plateau4_j1, true);
PropertyInfo? VictoireInfo4_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo4_j2);
VictoireInfo4_j2.SetValue(plateau4_j2, true);
MethodInfo? PlateauAjouterCodeInfo4 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo4);
PlateauAjouterCodeInfo4.Invoke(partie4, [null, new PlateauAjouterCodeEventArgs(plateau4_j1)]);
// Cas 5 : dernier joueur - true, plateau complet - false, victoire - false
Partie partie5 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo5 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo5 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo5 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo5);
Assert.NotNull(plateauxInfo5);
Assert.NotNull(courantInfo5);
Dictionary<string, bool>? joueurs5 = joueursInfo5.GetValue(partie5) as Dictionary<string, bool>;
List<Plateau>? plateaux5 = plateauxInfo5.GetValue(partie5) as List<Plateau>;
Assert.NotNull(joueurs5);
Assert.NotNull(plateaux5);
courantInfo5.SetValue(partie5, 1);
joueurs5.Add("Céleste", true);
joueurs5.Add("Pauline", true);
Plateau plateau5_j1 = new Plateau(1, 1);
Plateau plateau5_j2 = new Plateau(1, 1);
plateaux5.Add(plateau5_j1);
plateaux5.Add(plateau5_j2);
PropertyInfo? VictoireInfo5_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo5_j1);
VictoireInfo5_j1.SetValue(plateau5_j1, false);
PropertyInfo? VictoireInfo5_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo5_j2);
VictoireInfo5_j2.SetValue(plateau5_j2, false);
MethodInfo? PlateauAjouterCodeInfo5 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo5);
PlateauAjouterCodeInfo5.Invoke(partie5, [null, new PlateauAjouterCodeEventArgs(plateau5_j1)]);
// Cas 6 : dernier joueur - true, plateau complet - false, victoire - true
Partie partie6 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo6 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo6 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo6 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo6);
Assert.NotNull(plateauxInfo6);
Assert.NotNull(courantInfo6);
Dictionary<string, bool>? joueurs6 = joueursInfo6.GetValue(partie6) as Dictionary<string, bool>;
List<Plateau>? plateaux6 = plateauxInfo6.GetValue(partie6) as List<Plateau>;
Assert.NotNull(joueurs6);
Assert.NotNull(plateaux6);
courantInfo6.SetValue(partie6, 1);
joueurs6.Add("Céleste", true);
joueurs6.Add("Pauline", true);
Plateau plateau6_j1 = new Plateau(1, 1);
Plateau plateau6_j2 = new Plateau(1, 1);
plateaux6.Add(plateau6_j1);
plateaux6.Add(plateau6_j2);
PropertyInfo? VictoireInfo6_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo6_j1);
VictoireInfo6_j1.SetValue(plateau6_j1, true);
PropertyInfo? VictoireInfo6_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo6_j2);
VictoireInfo6_j2.SetValue(plateau6_j2, true);
MethodInfo? PlateauAjouterCodeInfo6 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo6);
PlateauAjouterCodeInfo6.Invoke(partie6, [null, new PlateauAjouterCodeEventArgs(plateau6_j1)]);
// Cas 7 : dernier joueur - true, plateau complet - true, victoire - false
Partie partie7 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo7 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo7 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo7 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo7);
Assert.NotNull(plateauxInfo7);
Assert.NotNull(courantInfo7);
Dictionary<string, bool>? joueurs7 = joueursInfo7.GetValue(partie7) as Dictionary<string, bool>;
List<Plateau>? plateaux7 = plateauxInfo7.GetValue(partie7) as List<Plateau>;
Assert.NotNull(joueurs7);
Assert.NotNull(plateaux7);
courantInfo7.SetValue(partie7, 1);
joueurs7.Add("Céleste", true);
joueurs7.Add("Pauline", true);
Plateau plateau7_j1 = new Plateau(1, 1);
Plateau plateau7_j2 = new Plateau(1, 1);
Code code7_j1 = new Code(1);
code7_j1.AjouterJeton(new Jeton(Couleur.Rouge));
Code code7_j2 = new Code(1);
code7_j2.AjouterJeton(new Jeton(Couleur.Rouge));
plateau7_j1.AjouterCode(code7_j1);
plateau7_j2.AjouterCode(code7_j2);
plateaux7.Add(plateau7_j1);
plateaux7.Add(plateau7_j2);
PropertyInfo? VictoireInfo7_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo7_j1);
VictoireInfo7_j1.SetValue(plateau7_j1, false);
PropertyInfo? VictoireInfo7_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo7_j2);
VictoireInfo7_j2.SetValue(plateau7_j2, false);
MethodInfo? PlateauAjouterCodeInfo7 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo7);
PlateauAjouterCodeInfo7.Invoke(partie7, [null, new PlateauAjouterCodeEventArgs(plateau7_j1)]);
// Cas 8 : dernier joueur - true, plateau complet - true, victoire - true
Partie partie8 = new Partie(new ReglesClassiques());
FieldInfo? joueursInfo8 = typeof(Partie).GetField("joueurs", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? plateauxInfo8 = typeof(Partie).GetField("plateaux", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo? courantInfo8 = typeof(Partie).GetField("courant", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(joueursInfo8);
Assert.NotNull(plateauxInfo8);
Assert.NotNull(courantInfo8);
Dictionary<string, bool>? joueurs8 = joueursInfo8.GetValue(partie8) as Dictionary<string, bool>;
List<Plateau>? plateaux8 = plateauxInfo8.GetValue(partie8) as List<Plateau>;
Assert.NotNull(joueurs8);
Assert.NotNull(plateaux8);
courantInfo8.SetValue(partie8, 1);
joueurs8.Add("Céleste", true);
joueurs8.Add("Pauline", true);
Plateau plateau8_j1 = new Plateau(1, 1);
Plateau plateau8_j2 = new Plateau(1, 1);
Code code8_j1 = new Code(1);
code8_j1.AjouterJeton(new Jeton(Couleur.Rouge));
Code code8_j2 = new Code(1);
code8_j2.AjouterJeton(new Jeton(Couleur.Rouge));
plateau8_j1.AjouterCode(code8_j1);
plateau8_j2.AjouterCode(code8_j2);
plateaux8.Add(plateau8_j1);
plateaux8.Add(plateau8_j2);
PropertyInfo? VictoireInfo8_j1 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo8_j1);
VictoireInfo8_j1.SetValue(plateau8_j1, true);
PropertyInfo? VictoireInfo8_j2 = typeof(Plateau).GetProperty("Victoire", BindingFlags.Public | BindingFlags.Instance);
Assert.NotNull(VictoireInfo8_j2);
VictoireInfo8_j2.SetValue(plateau8_j2, true);
MethodInfo? PlateauAjouterCodeInfo8 = typeof(Partie).GetMethod("PlateauAjouterCode", BindingFlags.NonPublic | BindingFlags.Instance);
Assert.NotNull(PlateauAjouterCodeInfo8);
PlateauAjouterCodeInfo8.Invoke(partie8, [null, new PlateauAjouterCodeEventArgs(plateau8_j1)]);
}
}
}

Loading…
Cancel
Save