Ajout de deux tests sur le calcul des zones + résolution d'un problème sur le code de cette même fonction
continuous-integration/drone/push Build is passing Details

pull/91/head
Remi NEVEU 11 months ago
parent 636cc3b722
commit d999520a9a

@ -197,7 +197,7 @@ namespace Models.Rules
calculus += zones[i].Count - 1 + zones[i][0].Value; calculus += zones[i].Count - 1 + zones[i][0].Value;
if (zones[i].Count > 9) if (zones[i].Count > 9)
{ {
calculus += (zones[i].Count - 9) * 5; calculus += (zones[i].Count - 9) * 5 - (zones[i].Count - 9);
} }
} }
return calculus; return calculus;

@ -462,17 +462,64 @@ public class RulesTests
Assert.Equal(0, rules.FinalCalculusOfZones(new List<List<Cell>>())); Assert.Equal(0, rules.FinalCalculusOfZones(new List<List<Cell>>()));
} }
/*
[Fact] [Fact]
public void FinalCalculusOfZones_ReturnsCorrectValue_WhenZonesAreNotEmpty() 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<List<Cell>> zones = new List<List<Cell>>
{
new List<Cell> { cell, cell1, cell2 },
new List<Cell> { uncell, deuxcell, troiscell }
};
Assert.Equal(9, rules.FinalCalculusOfZones(zones));
} }
[Fact] [Fact]
public void FinalCalculusOfZones_ReturnsCorrectValue_WhenZoneCountIsGreaterThanNine() 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<List<Cell>> zones = new List<List<Cell>>
{
new List<Cell> { cell, cell1, cell2, cell3, cell4, cell5, cell6, cell7, cell8, cell9, cell10 }
};
Assert.Equal(23, rules.FinalCalculusOfZones(zones));
} }
*/
} }
Loading…
Cancel
Save