|
|
|
@ -243,4 +243,68 @@ public class GameTests
|
|
|
|
|
|
|
|
|
|
Assert.True(isChecked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void IsPlaceOperationCorrect()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player();
|
|
|
|
|
var map = new Map("test_background");
|
|
|
|
|
|
|
|
|
|
_game.InitializeGame(map, player);
|
|
|
|
|
Assert.NotNull(_game.GameRules);
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 1;
|
|
|
|
|
_game.UsedMap.Boards[1].Value = 2;
|
|
|
|
|
|
|
|
|
|
var methodInfo = typeof(Game).GetMethod("PlaceResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
|
Assert.NotNull(methodInfo);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 2);
|
|
|
|
|
cell.Value = 3;
|
|
|
|
|
methodInfo.Invoke(_game, new object[] { cell, 3 });
|
|
|
|
|
|
|
|
|
|
Assert.Equal(3, _game.UsedMap.Boards[2].Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void IsHandlePlayerChoice_Handling()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player();
|
|
|
|
|
var map = new Map("test_background");
|
|
|
|
|
|
|
|
|
|
_game.InitializeGame(map, player);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 1);
|
|
|
|
|
_game.UsedMap.Boards[0].Value = 1;
|
|
|
|
|
bool result = _game.HandlePlayerChoice(cell, 1);
|
|
|
|
|
Assert.True(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void IsHandlePlayerChoice_InvalidCell()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player();
|
|
|
|
|
var map = new Map("test_background");
|
|
|
|
|
|
|
|
|
|
_game.InitializeGame(map, player);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 7);
|
|
|
|
|
cell.Value = 1;
|
|
|
|
|
bool result = _game.HandlePlayerChoice(cell, 1);
|
|
|
|
|
Assert.False(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void IsHandlePlayerChoice_InvalidPlace()
|
|
|
|
|
{
|
|
|
|
|
var player = new Player();
|
|
|
|
|
var map = new Map("test_background");
|
|
|
|
|
|
|
|
|
|
_game.InitializeGame(map, player);
|
|
|
|
|
|
|
|
|
|
var cell = new Cell(0, 0);
|
|
|
|
|
cell.Value = 1;
|
|
|
|
|
var othercell = new Cell(3, 3);
|
|
|
|
|
bool result = _game.HandlePlayerChoice(othercell, 1);
|
|
|
|
|
Assert.False(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|