public void ShouldCancelPlannedMove() { var game = new Game(new Board(2, 2, _ => false)); game.Board[new Position(0, 0)].Piece = new Spy(game.Players[0]); game.Board[new Position(1, 0)].Piece = new Spy(game.Players[1]); var viewModel = new GameViewModel(game); var cellPositions = GetCellPositions(viewModel); viewModel.Board[new Position(0, 0)].OnMouseOver(); viewModel.Board[new Position(0, 0)].OnClick(); cellPositions(c => c.IsPlannedMoveStart).Should().Equal(new Position(0, 0)); cellPositions(c => c.IsPossibleMove).Should().Equal(new Position(0, 1), new Position(1, 0)); cellPositions(c => c.IsPossibleAttack).Should().Equal(new Position(1, 0)); cellPositions(c => c.IsMouseOver).Should().Equal(new Position(0, 0)); viewModel.Board[new Position(1, 1)].OnMouseOver(); viewModel.Board[new Position(1, 1)].OnClick(); cellPositions(c => c.IsPlannedMoveStart).Should().BeEmpty(); cellPositions(c => c.IsPossibleMove).Should().BeEmpty(); cellPositions(c => c.IsPossibleAttack).Should().BeEmpty(); cellPositions(c => c.IsMouseOver).Should().Equal(new Position(1, 1)); }
public CellViewModel(GameViewModel game, Cell cell) { _game = game; Cell = cell; }
static Func <Func <CellViewModel, bool>, IEnumerable <Position> > GetCellPositions(GameViewModel game) => filter => game.Board.Cells.Where(filter).Select(c => c.Cell.Position);