public void EmptyPoint() { var builder = new GameBoardBuilder (); var board = builder.GetBoard (); Assert.That (board.IsEmpty(Point.Make(1, 1))); }
public Game(BoardView boardView) { m_boardView = boardView; GameBoardBuilder builder = new GameBoardBuilder (); AddGameUnity (builder,Point.Make(0,4)); m_logicBoard = builder.GetBoard (); m_currentSelection = m_logicBoard.Select (Point.Make(-1,-1)); m_boardView.OnCellClicked.Register((x,y) =>{ //TODO: Usar state pattern var point = Point.Make(x,y); Debug.Log(point); if(m_currentSelection.IsEmpty) { m_currentSelection = m_logicBoard.Select(point); } else { var visitor = new WalkVisitor(point); m_currentSelection.Commands.Visit(visitor); m_boardView.AddResult(visitor.Result); m_currentSelection = m_logicBoard.Select (Point.Make(-1,-1)); } }); }
public void EmptySelection() { var builder = new GameBoardBuilder (); var board = builder.GetBoard (); var selection = board.Select (Point.Make(1, 1)); Assert.That (selection.IsEmpty); }
public void NonEmptyPoint() { var builder = new GameBoardBuilder (); var board = builder.GetBoard (); var moq = new Mock<ISelectable> (); builder.AddSelectable (Point.Make(1, 1), moq.Object); Assert.That (!board.IsEmpty(Point.Make(1, 1))); }
public void SameSelectionObject() { var builder = new GameBoardBuilder (); var moq = new Mock<ISelectable> (); var moqSelection = new Mock<ISelection> (); moqSelection.SetupGet ((x) => x.IsEmpty).Returns (false); var ret = moqSelection.Object; moq.Setup ((x) => x.Select (It.IsAny<Point>(), It.IsAny<IBoardCommandFactory>())).Returns (ret); builder.AddSelectable (Point.Make(1, 1), moq.Object); var board = builder.GetBoard(); var selection = board.Select (Point.Make(1, 1)); Assert.AreEqual(ret,selection); }
public void WalkAUnit() { GameBoardBuilder builder = new GameBoardBuilder (); var unity = GameUnit.Basic ().CanWalk (10,10); var zeroPoint = Point.Make (0, 0); var selectable = new GameUnitSelectableAdapter (unity); builder.AddSelectable (zeroPoint, selectable); var board = builder.GetBoard (); var selection = board.Select (zeroPoint); var visitor = new WalkVisitor (Point.Make (1, 1)); selection.Commands.Visit (visitor); Assert.That (board.IsEmpty (zeroPoint)); }
public void WalkCmdDontHaveOrigin() { GameBoardBuilder builder = new GameBoardBuilder (); var unity = GameUnit.Basic ().CanWalk (10,10); var zeroPoint = Point.Make (0, 0); var selectable = new GameUnitSelectableAdapter (unity); builder.AddSelectable (zeroPoint, selectable); var board = builder.GetBoard (); var selection = board.Select (zeroPoint); var moq = new Mock<IBoardCommandsVisitor> (); moq.Setup((x) => x.WalkCommand(It.IsAny<IBoardWalkCommand>())).Callback<IBoardWalkCommand>((cmd)=>{ Assert.That(!cmd.PossiblePoints.Contains(zeroPoint)); }); selection.Commands.Visit (moq.Object); }