示例#1
0
        public void MovePacInCounterClockWiseCircle()
        {
            var service = new PacSimGridMovementService(3, 3);

            var startPos = service.Place(2, 2, PacDirection.WEST);

            service.Move();
            service.Move();

            service.Left();

            service.Move();
            service.Move();

            service.Left();

            service.Move();
            service.Move();

            service.Left();

            service.Move();
            service.Move();

            service.Left();

            var endPos = service.Report();

            Assert.AreEqual(startPos, endPos);
        }
示例#2
0
        public void MovePacInClockWiseCircle()
        {
            var service = new PacSimGridMovementService(3, 3);

            var startPos = service.Place(0, 0, PacDirection.NORTH);

            service.Move();
            service.Move();

            service.Right();

            service.Move();
            service.Move();

            service.Right();

            service.Move();
            service.Move();

            service.Right();

            service.Move();
            service.Move();

            service.Right();

            var endPos = service.Report();

            Assert.AreEqual(startPos, endPos);
        }
示例#3
0
        public void PlacePacOnFiveByFiveGrid_Invalid([Values(int.MinValue, -1, 5, int.MaxValue)] int x,
                                                     [Values(int.MinValue, -1, 5, int.MaxValue)] int y,
                                                     [Values(PacDirection.NORTH, PacDirection.SOUTH, PacDirection.EAST, PacDirection.WEST)] PacDirection facing)
        {
            var service = new PacSimGridMovementService(5, 5);

            Assert.Throws <ArgumentOutOfRangeException>(() => service.Place(x, y, facing));
        }
示例#4
0
        public void PlacePacOnFiveByFiveGrid_Valid([Range(0, 4)] int x, [Range(0, 4)] int y,
                                                   [Values(PacDirection.NORTH, PacDirection.SOUTH, PacDirection.EAST, PacDirection.WEST)] PacDirection facing)
        {
            var service = new PacSimGridMovementService(5, 5);

            var placedPosition = service.Place(x, y, facing);

            Assert.AreEqual(x, placedPosition.X);
            Assert.AreEqual(y, placedPosition.Y);
            Assert.AreEqual(facing, placedPosition.Facing);
        }
示例#5
0
        public void TurnPacRightOnGrid(PacDirection startFacing, PacDirection expectedFacing)
        {
            var service = new PacSimGridMovementService(1, 1);

            service.Place(0, 0, startFacing);

            service.Right();
            var newPos = service.Report();

            Assert.IsNotNull(newPos);
            Assert.AreEqual(expectedFacing, newPos.Value.Facing);
        }
示例#6
0
        public void MovePacOnGrid(int width, int height, int moveTimes, int startX, int startY, PacDirection startFacing, int expectedX, int expectedY)
        {
            var service = new PacSimGridMovementService(width, height);

            service.Place(startX, startY, startFacing);

            try
            {
                for (int i = 0; i < moveTimes; i++)
                {
                    service.Move();
                }
            }
            catch (Exception) { }

            var newPos = service.Report();

            Assert.IsNotNull(newPos);
            Assert.AreEqual(expectedX, newPos.Value.X, "X position doesn't match");
            Assert.AreEqual(expectedY, newPos.Value.Y, "Y position doesn't match");
        }