Пример #1
0
        public void RoverIsDeployedInUnacceptableLocation(string command)
        {
            // Arrange
            var plataue = new Plataeu();

            plataue.Define(1, 1);

            var manager           = new RoverSquadManager(plataue);
            var commandSplit      = command.Split(' ');
            var expectedX         = int.Parse(commandSplit[0]);
            var expectedY         = int.Parse(commandSplit[1]);
            var expectedDirection = Enum.Parse <Direction>(commandSplit[2]);

            // Act
            var action = new Action(() => manager.DeployRover(expectedX, expectedY, expectedDirection));

            // Assert
            action.Should().Throw <Exception>().WithMessage("Rover outside of bounds");
        }
Пример #2
0
        public void RoverIsDeployedInAcceptableLocation(string command)
        {
            // Arrange
            var plataue = new Plataeu();

            plataue.Define(10, 10);

            var manager           = new RoverSquadManager(plataue);
            var commandSplit      = command.Split(' ');
            var expectedX         = int.Parse(commandSplit[0]);
            var expectedY         = int.Parse(commandSplit[1]);
            var expectedDirection = Enum.Parse <Direction>(commandSplit[2]);

            // Act
            manager.DeployRover(expectedX, expectedY, expectedDirection);

            // Assert
            manager.Rovers.Single().X.Should().Be(expectedX);
            manager.Rovers.Single().Y.Should().Be(expectedY);
            manager.Rovers.Single().Direction.Should().Be(expectedDirection);
        }
Пример #3
0
        public void Move2NorthOn4X4MoveTwoBlocksUp(string command)
        {
            // Arrange
            var plataue = new Plataeu();

            plataue.Define(5, 5);
            var manager = new RoverSquadManager(plataue);

            manager.DeployRover(0, 0, Direction.N);
            var movements = command
                            .ToCharArray()
                            .Select(x => Enum.Parse <Movement>(x.ToString()))
                            .ToList();

            // Act
            movements.ForEach(manager.ActiveRover.Move);

            // Assert
            manager.ActiveRover.Should().NotBeNull();
            manager.ActiveRover.X.Should().Be(0);
            manager.ActiveRover.Y.Should().Be(2);
            manager.ActiveRover.Direction.Should().Be(Direction.N);
        }