Files
Giants/Tests/Giants.Core.Tests/Commands/NewMatchCommandTest.cs
mcmuzzle 3dba66344d
All checks were successful
check main state / build (9.0.x) (push) Successful in 2m46s
fin de l'initialisation d'un match et ajout du random aux commandes
2025-04-24 22:31:19 +02:00

45 lines
1.3 KiB
C#

namespace Giants.Core.Tests;
using Giants.Application;
using Giants.Core.Commands;
using Giants.Core.Interfaces;
using Giants.Infrastructure;
public class NewMatchCommandTest
{
private readonly IMatchRepository _repo;
public NewMatchCommandTest()
{
IHexagonalGrid _grid = new HexagonalGridImpl();
BoardLayout layout = new BoardLayout(_grid);
_repo = new MatchRepositoryMock(layout);
}
[Fact]
public void CreateBasicMatch()
{
Random random = new Random(1);
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
NewMatchResult result = command.Execute();
Assert.True(result.Success);
}
[Fact]
public void TwoNewMatchShouldHaveDifferentID()
{
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) { Random = random };
NewMatchResult result2 = command2.Execute();
Assert.True(result2.Success);
Assert.NotNull(result2.Match);
Assert.NotEqual(result.Match.Id, result2.Match.Id);
}
}