From 06206f1ef891e9c5c542ea76656736310498577a Mon Sep 17 00:00:00 2001 From: "pauline.prady" Date: Fri, 17 May 2024 17:15:02 +0200 Subject: [PATCH] Test Regles --- Sources/UnitTesting/ReglesClassiquesUT.cs | 26 +++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Sources/UnitTesting/ReglesClassiquesUT.cs b/Sources/UnitTesting/ReglesClassiquesUT.cs index 54b385d..e80bb8c 100644 --- a/Sources/UnitTesting/ReglesClassiquesUT.cs +++ b/Sources/UnitTesting/ReglesClassiquesUT.cs @@ -73,7 +73,6 @@ namespace UnitTesting int? joueurCourantAvant = (int?)fieldInfo.GetValue(regles); Assert.NotNull(joueurCourantAvant); - joueurCourantAvant++; if (joueurCourantAvant >= regles.NbJoueursMaximum) joueurCourantAvant = 0; @@ -85,7 +84,7 @@ namespace UnitTesting int? joueurCourantApres = (int?)fieldInfo.GetValue(regles); Assert.NotNull(joueurCourantApres); - Assert.Equal(joueurCourantAvant, joueurCourantApres); + Assert.NotEqual(joueurCourantAvant, joueurCourantApres); Assert.Equal("joueur2", joueurCourantSuivant.Nom); } @@ -159,8 +158,27 @@ namespace UnitTesting joueurCourant = null; Assert.Null(joueurCourant); - joueurCourant = 1; - Assert.Equal(1, joueurCourant); + bool result = regles.EstTerminee(); + + Assert.False(result); + } + + [Fact] + public void TestEstTermineeFalseJoueurCourantDiffDeZero() + { + ReglesClassiques regles = new ReglesClassiques(); + regles.AjouterJoueur("joueur1"); + regles.AjouterJoueur("joueur2"); + regles.CommencerLaPartie(); + + Type type = typeof(ReglesClassiques); + FieldInfo? fieldInfo = type.GetField("joueurCourant", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(fieldInfo); + + int? joueurCourant = (int?)fieldInfo.GetValue(regles); + + joueurCourant = -1; + Assert.Equal(-1, joueurCourant); bool result = regles.EstTerminee();