diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs index 73d4467..95859d7 100644 --- a/source/Trek-12/Models/Rules/Rules.cs +++ b/source/Trek-12/Models/Rules/Rules.cs @@ -197,7 +197,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