From 202cb64d8f4a39b08d2f6bd2cec6f926731767a0 Mon Sep 17 00:00:00 2001 From: "nicolas.barbosa" Date: Fri, 17 May 2024 21:22:28 +0200 Subject: [PATCH] TestPasserLaMain --- Sources/UnitTesting/ReglesClassiquesUT.cs | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Sources/UnitTesting/ReglesClassiquesUT.cs b/Sources/UnitTesting/ReglesClassiquesUT.cs index 1adbe60..d71eb28 100644 --- a/Sources/UnitTesting/ReglesClassiquesUT.cs +++ b/Sources/UnitTesting/ReglesClassiquesUT.cs @@ -30,6 +30,37 @@ namespace UnitTesting Assert.Throws(() => regles.PasserLaMain()); } + [Fact] + public void TestPasserLaMain() + { + ReglesClassiques regles = new ReglesClassiques(); + + regles.AjouterJoueur("céleste"); + regles.AjouterJoueur("pauline"); + regles.CommencerLaPartie(); + + Type type = typeof(ReglesClassiques); + + FieldInfo? fieldInfo = type.GetField("joueurCourant", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(fieldInfo); + + int? joueurCourant = (int?) fieldInfo.GetValue(regles); + Assert.NotNull(joueurCourant); + Assert.Equal(0, joueurCourant); + + regles.PasserLaMain(); + + joueurCourant = (int?)fieldInfo.GetValue(regles); + Assert.NotNull(joueurCourant); + Assert.Equal(1, joueurCourant); + + regles.PasserLaMain(); + + joueurCourant = (int?)fieldInfo.GetValue(regles); + Assert.NotNull(joueurCourant); + Assert.Equal(0, joueurCourant) + } + [Fact] public void TestEstTermineeVictoire() {