public void Execute_IfGridNotDefinedLandRover_Throws_Exception(string gridSize, string deploy, string moves)
        {
            // Arrange
            var commandCentre = new CommandCentre(_serviceProvider);

            // Act
            Action act = () => commandCentre.Dispatch(deploy);

            // Assert
            act.Should().Throw <Exception>().WithMessage("Plateau surface size not defined yet.");
        }
Exemple #2
0
        private static void CommandPad(IServiceProvider serviceProvider)
        {
            var commandCentre = new CommandCentre(serviceProvider);
            var command       = Console.ReadLine();

            while (command != "exit")
            {
                commandCentre.Dispatch(command);
                command = Console.ReadLine();
            }
        }
        public void Execute_OutOfGridBoundInput_Throws_Exception(string gridSize, string deploy)
        {
            // Arrange
            var commandCentre = new CommandCentre(_serviceProvider);

            commandCentre.Dispatch(gridSize);

            // Act
            Action act = () => commandCentre.Dispatch(deploy);

            // Assert
            act.Should().ThrowExactly <Exception>();
        }
Exemple #4
0
        public void Execute_CreatePlateau_InValidInputs_DoesnotCreatePlateau(string command)
        {
            // Arrange
            var commandCentre = new CommandCentre(_serviceProvider);

            // Act
            commandCentre.Dispatch(command);

            // Assert
            var plateau = _serviceProvider.GetService <IPlateau>();

            plateau.Size.Should().BeNull();
        }
        public void Execute_MoveRoverPositionInPlateauGrid_Expect_HeadingNorth(string gridSize, string deploy,
                                                                               string moves)
        {
            // Arrange
            var commandCentre = new CommandCentre(_serviceProvider);

            commandCentre.Dispatch(gridSize);
            commandCentre.Dispatch(deploy);
            var rover = _serviceProvider.GetService <IVehicle>();

            // Act
            commandCentre.Dispatch(moves);

            // Assert
            rover.Should().NotBeNull();
            rover.ReportPosition().Should().Be("3 3 N");
        }
Exemple #6
0
        public void Execute_CreatePlateauSetSize_ValidInputs_Success(string command)
        {
            // Arrange
            var commandItems   = command.Split(' ');
            var expectedWidth  = int.Parse(commandItems[0]) + 1;
            var expectedHeight = int.Parse(commandItems[1]) + 1;

            var commandCentre = new CommandCentre(_serviceProvider);

            // Act
            commandCentre.Dispatch(command);

            // Assert
            var plateau = _serviceProvider.GetService <IPlateau>();

            plateau.Should().NotBeNull();
            plateau.Size.Should().NotBeNull();
            plateau.Size.Should().NotBeNull();
            plateau.Size.Width.Should().Be(expectedWidth);
            plateau.Size.Height.Should().Be(expectedHeight);
        }