diff --git a/Sources/UnitTesting/ReglesClassiquesUT.cs b/Sources/UnitTesting/ReglesClassiquesUT.cs index 615974a..54b385d 100644 --- a/Sources/UnitTesting/ReglesClassiquesUT.cs +++ b/Sources/UnitTesting/ReglesClassiquesUT.cs @@ -65,11 +65,27 @@ namespace UnitTesting regles.AjouterJoueur("joueur2"); regles.CommencerLaPartie(); - Joueur joueurCourantInitial = regles.JoueurCourant(); + + Type type = typeof(ReglesClassiques); + FieldInfo? fieldInfo = type.GetField("joueurCourant", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(fieldInfo); + + int? joueurCourantAvant = (int?)fieldInfo.GetValue(regles); + Assert.NotNull(joueurCourantAvant); + + joueurCourantAvant++; + if (joueurCourantAvant >= regles.NbJoueursMaximum) + joueurCourantAvant = 0; + regles.PasserLaMain(); Joueur joueurCourantSuivant = regles.JoueurCourant(); - Assert.NotEqual(joueurCourantInitial, joueurCourantSuivant); + Assert.Equal(regles.JoueurCourant(), joueurCourantSuivant); + + int? joueurCourantApres = (int?)fieldInfo.GetValue(regles); + Assert.NotNull(joueurCourantApres); + + Assert.Equal(joueurCourantAvant, joueurCourantApres); Assert.Equal("joueur2", joueurCourantSuivant.Nom); } @@ -127,12 +143,24 @@ namespace UnitTesting } [Fact] - public void TestEstTermineeFalseUnJoueur() + public void TestEstTermineeFalseJoueurCourantNull() { ReglesClassiques regles = new ReglesClassiques(); regles.AjouterJoueur("joueur1"); + regles.AjouterJoueur("joueur2"); regles.CommencerLaPartie(); - regles.PasserLaMain(); + + Type type = typeof(ReglesClassiques); + FieldInfo? fieldInfo = type.GetField("joueurCourant", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(fieldInfo); + + int? joueurCourant = (int?)fieldInfo.GetValue(regles); + + joueurCourant = null; + Assert.Null(joueurCourant); + + joueurCourant = 1; + Assert.Equal(1, joueurCourant); bool result = regles.EstTerminee(); @@ -173,7 +201,7 @@ namespace UnitTesting } [Fact] - public void TestEstTermineeToursMaximesAtteints() + public void TestEstTermineeToursMaximumAtteints() { ReglesClassiques regles = new ReglesClassiques(); Partie partie = new Partie(regles); @@ -191,8 +219,6 @@ namespace UnitTesting Assert.True(estTerminee); } - - [Fact] public void TestGagnantsAucunGagnants() {