Пример #1
0
	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)));
	}
Пример #2
0
	void AddGameUnity(GameBoardBuilder builder, Point p)
	{
		var unit = GameUnit.Basic ().CanWalk (10,10);
		var selectable = new GameUnitSelectableAdapter (unit);


		m_boardView.AddUnitView (p);
	
		builder.AddSelectable (p,selectable);
	}
Пример #3
0
	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);
	}