ajout du boardlayout et de la commande getmatch
This commit was merged in pull request #8.
This commit is contained in:
45
Tests/Giants.Core.Tests/Commands/GetMatchCommandTest.cs
Normal file
45
Tests/Giants.Core.Tests/Commands/GetMatchCommandTest.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
namespace Giants.Core.Tests;
|
||||
|
||||
using Giants.Application;
|
||||
using Giants.Core.Commands;
|
||||
using Giants.Core.Interfaces;
|
||||
using Giants.Infrastructure;
|
||||
|
||||
public class GetMatchCommandTest
|
||||
{
|
||||
private readonly IMatchRepository _repo;
|
||||
|
||||
public GetMatchCommandTest()
|
||||
{
|
||||
IHexagonalGrid _grid = new HexagonalGridImpl();
|
||||
BoardLayout layout = new BoardLayout(_grid);
|
||||
_repo = new MatchRepositoryMock(layout);
|
||||
|
||||
var match1 = _repo.CreateMatch();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMatchNotExisting()
|
||||
{
|
||||
GetMatchCommand command = new GetMatchCommand(_repo)
|
||||
{
|
||||
MatchId = 2
|
||||
};
|
||||
GetMatchResult result = command.Execute();
|
||||
Assert.False(result.Success);
|
||||
Assert.Null(result.Match);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMatchSimple()
|
||||
{
|
||||
GetMatchCommand command = new GetMatchCommand(_repo)
|
||||
{
|
||||
MatchId = 1
|
||||
};
|
||||
GetMatchResult result = command.Execute();
|
||||
Assert.True(result.Success);
|
||||
Assert.NotNull(result.Match);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,10 +3,18 @@ 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 = new MatchRepositoryMock();
|
||||
private readonly IMatchRepository _repo;
|
||||
|
||||
public NewMatchCommandTest()
|
||||
{
|
||||
IHexagonalGrid _grid = new HexagonalGridImpl();
|
||||
BoardLayout layout = new BoardLayout(_grid);
|
||||
_repo = new MatchRepositoryMock(layout);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CreateBasicMatch()
|
||||
|
||||
46
Tests/Giants.Core.Tests/Entities/BoardLayoutTests.cs
Normal file
46
Tests/Giants.Core.Tests/Entities/BoardLayoutTests.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Giants.Core.Interfaces;
|
||||
using Giants.Infrastructure;
|
||||
|
||||
namespace Giants.Core.Tests;
|
||||
|
||||
public class BoardLayoutTests
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void TestNeighbour()
|
||||
{
|
||||
IHexagonalGrid grid = new HexagonalGridImpl();
|
||||
BoardLayout layout = new BoardLayout(grid);
|
||||
|
||||
var test = layout.GetNeighbours(new AxialCoords(2, 6)).ToList();
|
||||
foreach (var voisin in new List<AxialCoords>() {
|
||||
new AxialCoords(3,5),
|
||||
new AxialCoords(1,6),
|
||||
new AxialCoords(3,6),
|
||||
new AxialCoords(2,5),
|
||||
new AxialCoords(2,7),
|
||||
})
|
||||
{
|
||||
Assert.Contains(voisin, test);
|
||||
}
|
||||
Assert.Equal(5, test.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestNeighbourWhenAhu()
|
||||
{
|
||||
IHexagonalGrid grid = new HexagonalGridImpl();
|
||||
BoardLayout layout = new BoardLayout(grid);
|
||||
|
||||
var test = layout.GetNeighbours(new AxialCoords(14, -2)).ToList();
|
||||
foreach (var voisin in new List<AxialCoords>() {
|
||||
new AxialCoords(13,-2),
|
||||
new AxialCoords(13,-1),
|
||||
new AxialCoords(14,-1),
|
||||
})
|
||||
{
|
||||
Assert.Contains(voisin, test);
|
||||
}
|
||||
Assert.Equal(3, test.Count);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user