コード例 #1
0
        public static void OnlyMoveToEmptySpace(int pos, int[] moves, Color c)
        {
            IBoard board = Substitute.For <IBoard>();

            board.Occupant(Arg.Any <int>()).Returns(new Cow(-1, c));
            IPlayer P   = Substitute.For <IPlayer>();
            ICowBox box = Substitute.For <ICowBox>();

            box.RemainingCows(Arg.Any <Color>()).Returns(12);
            IReferee r = new Referee(board, box);

            if (c == Color.Red)
            {
                foreach (int m1 in moves)
                {
                    Assert.False(r.CanMove(Color.Red, pos, m1, Phase.Moving));
                }
            }
            if (c == Color.Black)
            {
                foreach (int m2 in moves)
                {
                    Assert.True(r.CanMove(Color.Red, pos, m2, Phase.Moving));
                }
            }
        }
コード例 #2
0
        public void CowCanOnlyMoveToConnectedSpace()
        {
            int[] allMoves = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };

            for (int i = 0; i < 24; i++)
            {
                IBoard  b   = new Board();
                ICowBox box = Substitute.For <ICowBox>();
                box.TakeCow(Arg.Any <Color>()).Returns(new Cow(-1, Color.Red));

                IReferee r = new Referee(b, box);

                b.Place(new Cow(-1, Color.Red), i);

                int[] ValidMoves   = b.ConnectedSpaces(i);
                int[] inValidMoves = allMoves.Where(x => !ValidMoves.Contains(x)).ToArray();

                foreach (int a in ValidMoves)
                {
                    Assert.True(r.CanMove(Color.Red, i, a, Phase.Moving));
                }
                foreach (int z in inValidMoves)
                {
                    Assert.False(r.CanMove(Color.Red, i, z, Phase.Moving));
                }
            }
        }