fin de l'initialisation d'un match et ajout du random aux commandes
All checks were successful
check main state / build (9.0.x) (push) Successful in 2m46s
All checks were successful
check main state / build (9.0.x) (push) Successful in 2m46s
This commit was merged in pull request #29.
This commit is contained in:
@@ -21,10 +21,13 @@ public class GetMatchCommandTest
|
||||
[Fact]
|
||||
public void GetMatchNotExisting()
|
||||
{
|
||||
Random random = new Random(1);
|
||||
GetMatchCommand command = new GetMatchCommand(_repo)
|
||||
{
|
||||
MatchId = 2
|
||||
MatchId = 2,
|
||||
Random = random
|
||||
};
|
||||
|
||||
GetMatchResult result = command.Execute();
|
||||
Assert.False(result.Success);
|
||||
Assert.Null(result.Match);
|
||||
@@ -33,9 +36,11 @@ public class GetMatchCommandTest
|
||||
[Fact]
|
||||
public void GetMatchSimple()
|
||||
{
|
||||
Random random = new Random(1);
|
||||
GetMatchCommand command = new GetMatchCommand(_repo)
|
||||
{
|
||||
MatchId = 1
|
||||
MatchId = 1,
|
||||
Random = random
|
||||
};
|
||||
GetMatchResult result = command.Execute();
|
||||
Assert.True(result.Success);
|
||||
|
||||
@@ -19,7 +19,8 @@ public class NewMatchCommandTest
|
||||
[Fact]
|
||||
public void CreateBasicMatch()
|
||||
{
|
||||
NewMatchCommand command = new NewMatchCommand(_repo);
|
||||
Random random = new Random(1);
|
||||
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
|
||||
NewMatchResult result = command.Execute();
|
||||
Assert.True(result.Success);
|
||||
}
|
||||
@@ -27,12 +28,13 @@ public class NewMatchCommandTest
|
||||
[Fact]
|
||||
public void TwoNewMatchShouldHaveDifferentID()
|
||||
{
|
||||
NewMatchCommand command = new NewMatchCommand(_repo);
|
||||
Random random = new Random(1);
|
||||
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
|
||||
NewMatchResult result = command.Execute();
|
||||
Assert.True(result.Success);
|
||||
Assert.NotNull(result.Match);
|
||||
|
||||
NewMatchCommand command2 = new NewMatchCommand(_repo);
|
||||
NewMatchCommand command2 = new NewMatchCommand(_repo) { Random = random };
|
||||
NewMatchResult result2 = command2.Execute();
|
||||
Assert.True(result2.Success);
|
||||
Assert.NotNull(result2.Match);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Giants.Application;
|
||||
using Giants.Core.Commands;
|
||||
using Giants.Core.Enums;
|
||||
using Giants.Core.Interfaces;
|
||||
using Giants.Infrastructure;
|
||||
|
||||
@@ -19,12 +20,13 @@ public class PrepareMatchCommandTest
|
||||
[Fact]
|
||||
void SimpleInit5Players()
|
||||
{
|
||||
NewMatchCommand command = new NewMatchCommand(_repo);
|
||||
Random random = new Random(1);
|
||||
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
|
||||
NewMatchResult result = command.Execute();
|
||||
Match? m = result.Match;
|
||||
Assert.NotNull(m);
|
||||
|
||||
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14, 9 } };
|
||||
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14, 9 }, Random = random };
|
||||
var resultPrep = prepCommand.Execute();
|
||||
Assert.True(resultPrep.Success);
|
||||
Assert.NotNull(resultPrep?.Match);
|
||||
@@ -34,24 +36,29 @@ public class PrepareMatchCommandTest
|
||||
Player? p = resultPrep.Match.GetPlayer(i);
|
||||
Assert.NotNull(p);
|
||||
|
||||
Assert.Equal(2, p.NbVisibleTribalTokenCount);
|
||||
Assert.Equal(0, p.NbHiddenTribalTokenCount);
|
||||
Assert.Equal(0, p.NbVisibleTribalTokenCount);
|
||||
Assert.Equal(2, p.NbHiddenTribalTokenCount);
|
||||
Assert.Equal(4, p.NbUrnTribalTokenCount);
|
||||
Assert.Equal(5, p.NbVisibleBase);
|
||||
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Chef));
|
||||
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Shaman));
|
||||
Assert.Equal(5, p.NbHiddenBase);
|
||||
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Chef));
|
||||
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Shaman));
|
||||
Assert.Equal(1, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == p.HiddenPosition));
|
||||
Assert.Equal(5, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == Enums.PiecePosition.Urne));
|
||||
Assert.Equal(0, p.Score);
|
||||
Assert.NotEqual(PiecePosition.boite, resultPrep.Match.GetPiece(PieceIndex.StartPlayer));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void SimpleInit4Players()
|
||||
{
|
||||
NewMatchCommand command = new NewMatchCommand(_repo);
|
||||
Random random = new Random(1);
|
||||
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
|
||||
NewMatchResult result = command.Execute();
|
||||
Match? m = result.Match;
|
||||
Assert.NotNull(m);
|
||||
|
||||
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14 } };
|
||||
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14 }, Random = random };
|
||||
var resultPrep = prepCommand.Execute();
|
||||
Assert.True(resultPrep.Success);
|
||||
Assert.NotNull(resultPrep?.Match);
|
||||
@@ -61,24 +68,29 @@ public class PrepareMatchCommandTest
|
||||
Player? p = resultPrep.Match.GetPlayer(i);
|
||||
Assert.NotNull(p);
|
||||
|
||||
Assert.Equal(2, p.NbVisibleTribalTokenCount);
|
||||
Assert.Equal(0, p.NbHiddenTribalTokenCount);
|
||||
Assert.Equal(0, p.NbVisibleTribalTokenCount);
|
||||
Assert.Equal(2, p.NbHiddenTribalTokenCount);
|
||||
Assert.Equal(4, p.NbUrnTribalTokenCount);
|
||||
Assert.Equal(6, p.NbVisibleBase);
|
||||
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Chef));
|
||||
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Shaman));
|
||||
Assert.Equal(6, p.NbHiddenBase);
|
||||
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Chef));
|
||||
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Shaman));
|
||||
Assert.Equal(1, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == p.HiddenPosition));
|
||||
Assert.Equal(5, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == Enums.PiecePosition.Urne));
|
||||
Assert.Equal(0, p.Score);
|
||||
Assert.NotEqual(PiecePosition.boite, resultPrep.Match.GetPiece(PieceIndex.StartPlayer));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
void SimpleInit3Players()
|
||||
{
|
||||
NewMatchCommand command = new NewMatchCommand(_repo);
|
||||
Random random = new Random(1);
|
||||
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
|
||||
NewMatchResult result = command.Execute();
|
||||
Match? m = result.Match;
|
||||
Assert.NotNull(m);
|
||||
|
||||
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5 } };
|
||||
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5 }, Random = random };
|
||||
var resultPrep = prepCommand.Execute();
|
||||
Assert.True(resultPrep.Success);
|
||||
Assert.NotNull(resultPrep?.Match);
|
||||
@@ -88,12 +100,16 @@ public class PrepareMatchCommandTest
|
||||
Player? p = resultPrep.Match.GetPlayer(i);
|
||||
Assert.NotNull(p);
|
||||
|
||||
Assert.Equal(2, p.NbVisibleTribalTokenCount);
|
||||
Assert.Equal(0, p.NbHiddenTribalTokenCount);
|
||||
Assert.Equal(0, p.NbVisibleTribalTokenCount);
|
||||
Assert.Equal(2, p.NbHiddenTribalTokenCount);
|
||||
Assert.Equal(4, p.NbUrnTribalTokenCount);
|
||||
Assert.Equal(7, p.NbVisibleBase);
|
||||
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Chef));
|
||||
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Shaman));
|
||||
Assert.Equal(7, p.NbHiddenBase);
|
||||
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Chef));
|
||||
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Shaman));
|
||||
Assert.Equal(1, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == p.HiddenPosition));
|
||||
Assert.Equal(5, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == Enums.PiecePosition.Urne));
|
||||
Assert.Equal(0, p.Score);
|
||||
Assert.NotEqual(PiecePosition.boite, resultPrep.Match.GetPiece(PieceIndex.StartPlayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,4 +52,16 @@ public class BoardLayoutTests
|
||||
BoardLayout layout = new BoardLayout(grid);
|
||||
Assert.Equal(PiecePosition.tile144, layout.FromTileIndex(144));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CheckForestQuantities()
|
||||
{
|
||||
IHexagonalGrid grid = new HexagonalGridImpl();
|
||||
BoardLayout layout = new BoardLayout(grid);
|
||||
|
||||
int forest1Index = layout.ForestIndex(new AxialCoords(4, 2));
|
||||
Assert.Equal(0, forest1Index);
|
||||
int qteForest1 = layout.ForestQte(forest1Index);
|
||||
Assert.Equal(5, qteForest1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user