Esempio n. 1
0
        public void PacManCantMoveIfItDoesNotExist()
        {
            var grid         = new Grid(4, 8);
            var somePosition = new Position(2, 1);

            Assert.Throws <InvalidMoveException>(() => grid.MovePacManTo(somePosition));
        }
Esempio n. 2
0
        public void WithPacmansHeadYouDontBreakThrough()
        {
            var grid                 = new Grid(4, 8);
            var originPosition       = new Position(0, 0);
            var positionNextToActual = new Position(-1, 0);

            grid.PlacePacManAt(originPosition);
            Assert.Throws <InvalidMoveException>(() => grid.MovePacManTo(positionNextToActual));
        }
Esempio n. 3
0
        public void AllCellsVisitedByPacManAreNotFilledWithDots()
        {
            var grid = new Grid(4, 8);
            var originPosition = new Position(0, 0);
            var positionNextToActual = new Position(1, 0);

            grid.PlacePacManAt(originPosition);
            grid.MovePacManTo(positionNextToActual);
            Assert.NotEqual(Grid.FilledCell, grid.At(originPosition));
        }
Esempio n. 4
0
        public void AllCellsVisitedByPacManAreNotFilledWithDots()
        {
            var grid                 = new Grid(4, 8);
            var originPosition       = new Position(0, 0);
            var positionNextToActual = new Position(1, 0);

            grid.PlacePacManAt(originPosition);
            grid.MovePacManTo(positionNextToActual);
            Assert.NotEqual(Grid.FilledCell, grid.At(originPosition));
        }
Esempio n. 5
0
        public void PacManCantMoveToWall()
        {
            var grid         = new Grid(4, 8);
            var positionWall = new Position(2, 0);

            grid.PlaceWall(positionWall);
            var originPosition       = new Position(0, 0);
            var positionNextToActual = new Position(2, 0);

            grid.PlacePacManAt(originPosition);
            Assert.Throws <InvalidMoveException>(() => grid.MovePacManTo(positionNextToActual));
        }
Esempio n. 6
0
        public void Tick()
        {
            Position newPosition = default(Position);

            switch (PacmanDirection)
            {
            case Direction.Down:
                newPosition = Position.GetDown(_grid.PacmanPosition.Value);
                break;

            case Direction.Up:
                newPosition = Position.GetUp(_grid.PacmanPosition.Value);
                break;

            case Direction.Right:
                newPosition = Position.GetRight(_grid.PacmanPosition.Value);
                break;

            case Direction.Left:
                newPosition = Position.GetLeft(_grid.PacmanPosition.Value);
                break;
            }
            _grid.MovePacManTo(newPosition);
        }
Esempio n. 7
0
        public void WithPacmansHeadYouDontBreakThrough()
        {
            var grid = new Grid(4, 8);
            var originPosition = new Position(0, 0);
            var positionNextToActual = new Position(-1, 0);

            grid.PlacePacManAt(originPosition);
            Assert.Throws<InvalidMoveException>(() => grid.MovePacManTo(positionNextToActual));
        }
Esempio n. 8
0
        public void PacManCantMoveToWall()
        {
            var grid = new Grid(4, 8);
            var positionWall = new Position(2, 0);
            grid.PlaceWall(positionWall);
            var originPosition = new Position(0, 0);
            var positionNextToActual = new Position(2, 0);

            grid.PlacePacManAt(originPosition);
            Assert.Throws<InvalidMoveException>(() => grid.MovePacManTo(positionNextToActual));
        }
Esempio n. 9
0
        public void PacManCantMoveIfItDoesNotExist()
        {
            var grid = new Grid(4, 8);
            var somePosition = new Position(2, 1);

            Assert.Throws<InvalidMoveException>(() => grid.MovePacManTo(somePosition));
        }