Files
Giants/Tests/Giants.Core.Tests/Commands/PrepareMatchCommandTest.cs
mcmuzzle 90c93df9c9
All checks were successful
check main state / build (9.0.x) (push) Successful in 1m26s
ajout des marker et des socles aux joueurs au debut de la partie
2025-04-23 16:38:26 +02:00

93 lines
2.9 KiB
C#

using Giants.Application;
using Giants.Core.Commands;
using Giants.Core.Interfaces;
using Giants.Infrastructure;
namespace Giants.Core.Tests;
public class PrepareMatchCommandTest
{
private readonly IMatchRepository _repo;
public PrepareMatchCommandTest()
{
IHexagonalGrid _grid = new HexagonalGridImpl();
BoardLayout layout = new BoardLayout(_grid);
_repo = new MatchRepositoryMock(layout);
}
[Fact]
void SimpleInit5Players()
{
NewMatchCommand command = new NewMatchCommand(_repo);
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 } };
var resultPrep = prepCommand.Execute();
Assert.True(resultPrep.Success);
Assert.NotNull(resultPrep?.Match);
for (int i = 0; i < 5; i++)
{
Player? p = resultPrep.Match.GetPlayer(i);
Assert.NotNull(p);
Assert.Equal(2, p.NbVisibleTribalTokenCount);
Assert.Equal(0, p.NbHiddenTribalTokenCount);
Assert.Equal(4, p.NbUrnTribalTokenCount);
Assert.Equal(5, p.NbVisibleBase);
}
}
[Fact]
void SimpleInit4Players()
{
NewMatchCommand command = new NewMatchCommand(_repo);
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 } };
var resultPrep = prepCommand.Execute();
Assert.True(resultPrep.Success);
Assert.NotNull(resultPrep?.Match);
for (int i = 0; i < 4; i++)
{
Player? p = resultPrep.Match.GetPlayer(i);
Assert.NotNull(p);
Assert.Equal(2, p.NbVisibleTribalTokenCount);
Assert.Equal(0, p.NbHiddenTribalTokenCount);
Assert.Equal(4, p.NbUrnTribalTokenCount);
Assert.Equal(6, p.NbVisibleBase);
}
}
[Fact]
void SimpleInit3Players()
{
NewMatchCommand command = new NewMatchCommand(_repo);
NewMatchResult result = command.Execute();
Match? m = result.Match;
Assert.NotNull(m);
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5 } };
var resultPrep = prepCommand.Execute();
Assert.True(resultPrep.Success);
Assert.NotNull(resultPrep?.Match);
for (int i = 0; i < 3; i++)
{
Player? p = resultPrep.Match.GetPlayer(i);
Assert.NotNull(p);
Assert.Equal(2, p.NbVisibleTribalTokenCount);
Assert.Equal(0, p.NbHiddenTribalTokenCount);
Assert.Equal(4, p.NbUrnTribalTokenCount);
Assert.Equal(7, p.NbVisibleBase);
}
}
}