From 407ded9e147bf2444f61d3950dd62c26977a26f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi?= Date: Fri, 31 May 2024 08:28:15 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20deux=20tests=20sur=20le=20calcul?= =?UTF-8?q?=20des=20zones=20+=20r=C3=A9solution=20d'un=20probl=C3=A8me=20s?= =?UTF-8?q?ur=20le=20code=20de=20cette=20m=C3=AAme=20fonction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Models/Rules/Rules.cs | 2 +- source/Trek-12/Tests/RulesTests.cs | 55 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs index 6fa645a..341d1ff 100644 --- a/source/Trek-12/Models/Rules/Rules.cs +++ b/source/Trek-12/Models/Rules/Rules.cs @@ -232,7 +232,7 @@ namespace Models.Rules calculus += zones[i].Count - 1 + zones[i][0].Value; if (zones[i].Count > 9) { - calculus += (zones[i].Count - 9) * 5; + calculus += (zones[i].Count - 9) * 5 - (zones[i].Count - 9); } } return calculus; diff --git a/source/Trek-12/Tests/RulesTests.cs b/source/Trek-12/Tests/RulesTests.cs index 630cca2..7cfe05a 100644 --- a/source/Trek-12/Tests/RulesTests.cs +++ b/source/Trek-12/Tests/RulesTests.cs @@ -462,17 +462,64 @@ public class RulesTests Assert.Equal(0, rules.FinalCalculusOfZones(new List>())); } - /* [Fact] public void FinalCalculusOfZones_ReturnsCorrectValue_WhenZonesAreNotEmpty() { - // TODO + Rules rules = new Rules(); + Cell cell = new Cell(0, 0); + cell.Value = 1; + Cell cell1 = new Cell(0, 1); + cell1.Value = 1; + Cell cell2 = new Cell(0, 2); + cell2.Value = 1; + Cell uncell = new Cell(0, 0); + uncell.Value = 4; + Cell deuxcell = new Cell(0, 1); + deuxcell.Value = 4; + Cell troiscell = new Cell(0, 2); + troiscell.Value = 4; + List> zones = new List> + { + new List { cell, cell1, cell2 }, + new List { uncell, deuxcell, troiscell } + }; + + Assert.Equal(9, rules.FinalCalculusOfZones(zones)); } [Fact] public void FinalCalculusOfZones_ReturnsCorrectValue_WhenZoneCountIsGreaterThanNine() { - // TODO + Rules rules = new Rules(); + Cell cell = new Cell(0, 0); + cell.Value = 5; + Cell cell1 = new Cell(0, 1); + cell1.Value = 5; + Cell cell2 = new Cell(0, 2); + cell2.Value = 5; + Cell cell3 = new Cell(0, 3); + cell3.Value = 5; + Cell cell4 = new Cell(0, 4); + cell4.Value = 5; + Cell cell5 = new Cell(0, 5); + cell5.Value = 5; + Cell cell6 = new Cell(1, 0); + cell6.Value = 5; + Cell cell7 = new Cell(1, 1); + cell7.Value = 5; + Cell cell8 = new Cell(1, 2); + cell8.Value = 5; + Cell cell9 = new Cell(1, 3); + cell9.Value = 5; + Cell cell10 = new Cell(1, 4); + cell10.Value = 5; + + List> zones = new List> + { + new List { cell, cell1, cell2, cell3, cell4, cell5, cell6, cell7, cell8, cell9, cell10 } + }; + + Assert.Equal(23, rules.FinalCalculusOfZones(zones)); } - */ + } \ No newline at end of file