static void Main(string[] args) { Console.WriteLine("__Test Input:__"); Console.WriteLine(); var plateau = new Plataeu(); plateau.Define("5 5"); Console.WriteLine(plateau.ToString()); var roverFirst = new Rover(plateau, "1 2 N"); Console.WriteLine(roverFirst.StartPosition.ToString()); roverFirst.SetControlCommands("LMLMLMLMM"); Console.WriteLine(roverFirst.ControlsString); roverFirst.Deploy(); var roverSecond = new Rover(plateau, "3 3 E"); Console.WriteLine(roverSecond.StartPosition.ToString()); roverSecond.SetControlCommands("MMRMMRMRRM"); Console.WriteLine(roverSecond.ControlsString); roverSecond.Deploy(); Console.WriteLine(); Console.WriteLine("__Expected Output:__"); Console.WriteLine(); Console.WriteLine(roverFirst.ToString()); Console.WriteLine(roverSecond.ToString()); Console.WriteLine(); Console.ReadLine(); }
public void WhenCoordinatesAreGiven_ThenShouldThrowException(string command) { // Arrange var plataeu = new Plataeu(); // Act, Assert Assert.Throws <CommandFormatException>(() => plataeu.Define(command)); }
public void WhenCoordinatesAreGiven_ThenShouldDefinePlateau(string command, int width, int height) { // Arrange var plataeu = new Plataeu(); // Act plataeu.Define(command); // Assert Assert.Equal(width, plataeu.Size.Width); Assert.Equal(height, plataeu.Size.Height); }
public void TwoNumbersGeneratePlataueWithCorrectSize(string command) { // Arrange var landingSurface = new Plataeu(); var commandSplit = command.Split(' '); var expectedWidth = int.Parse(commandSplit[0]) + 1; var expectedHeight = int.Parse(commandSplit[1]) + 1; // Act landingSurface.Define(expectedWidth, expectedHeight); // Assert landingSurface.Size.Width.Should().Be(expectedWidth); landingSurface.Size.Height.Should().Be(expectedHeight); }
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"); }
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); }
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); }
public ControlCommandTests() { plateau = new Plataeu(); plateau.Define("5 5"); }
public RoverTests() { plateau = new Plataeu(); plateau.Define("5 5"); }