From 9ed620538d29563f18b6529e4e83f52c1f63ceac Mon Sep 17 00:00:00 2001 From: victor perez ngounou Date: Sat, 1 Oct 2022 23:28:42 +0200 Subject: [PATCH] . --- Sources/BowlingLib/Model/Frame.cs | 2 +- Sources/BowlingLib/Model/Partie.cs | 19 ++--- Sources/Tests/BowlingAppUnitTest/UTPartie.cs | 82 +++++++++++++++++++- 3 files changed, 90 insertions(+), 13 deletions(-) diff --git a/Sources/BowlingLib/Model/Frame.cs b/Sources/BowlingLib/Model/Frame.cs index 7638e41..351d39e 100644 --- a/Sources/BowlingLib/Model/Frame.cs +++ b/Sources/BowlingLib/Model/Frame.cs @@ -148,7 +148,7 @@ namespace BowlingLib.Model this.IsSpare = true; } } - if (this.QuillesRestantes == 0 || this.Lancer2 != null) + if (this.QuillesRestantes == 0 || (this.Lancer2 != null && this.Numero != 10)) { this.IsFinished = true; } diff --git a/Sources/BowlingLib/Model/Partie.cs b/Sources/BowlingLib/Model/Partie.cs index 2003ce0..a9c1dcc 100644 --- a/Sources/BowlingLib/Model/Partie.cs +++ b/Sources/BowlingLib/Model/Partie.cs @@ -30,21 +30,18 @@ namespace BowlingLib.Model for (int i = 0; i < Frames.Count; i++) { score += Frames[i].QuillesTombees; - if (i listParties = stubPartie.ListParties(); + Partie partie = listParties[0]; + partie.AddFrame(new Frame(1)); + partie.AddFrame(new Frame(2)); + partie.AddFrame(new Frame(3)); + partie.AddFrame(new Frame(4)); + partie.AddFrame(new Frame(5)); + partie.AddFrame(new Frame(6)); + partie.AddFrame(new Frame(7)); + partie.AddFrame(new Frame(8)); + partie.AddFrame(new Frame(9)); + partie.AddFrame(new Frame(10)); + + for (int i = 0; i < partie.Frames.Count; i++) + { + partie.Frames[i].Lancer(5); + partie.Frames[i].Lancer(5); + if (partie.Frames.Count==10) + { + partie.Frames[i].Lancer(5); + } + } + + //Act + int? score = partie.GetScore(); + + //Assert + Assert.Equal(150, score); + } + + //le cas ou le joueur fait que des spares et des strikes + + [Fact] + + public void TestGetScore3() + { + //Arrange + StubPartie stubPartie = new StubPartie(); + List listParties = stubPartie.ListParties(); + Partie partie = listParties[0]; + partie.AddFrame(new Frame(1)); + partie.AddFrame(new Frame(2)); + partie.AddFrame(new Frame(3)); + partie.AddFrame(new Frame(4)); + partie.AddFrame(new Frame(5)); + partie.AddFrame(new Frame(6)); + partie.AddFrame(new Frame(7)); + partie.AddFrame(new Frame(8)); + partie.AddFrame(new Frame(9)); + partie.AddFrame(new Frame(10)); + + for (int i = 0; i < partie.Frames.Count; i++) + { + if (i % 2 == 0) + { + partie.Frames[i].Lancer(10); + } + else + { + partie.Frames[i].Lancer(5); + partie.Frames[i].Lancer(5); + } + } + + //Act + int? score = partie.GetScore(); + + //Assert + Assert.Equal(200, score); + } } } \ No newline at end of file