public void Test_CreateSurface(string size) { SurfaceHandler _surfaceHandler = new SurfaceHandler(); var surface = _surfaceHandler.CreateSurface(size); Assert.NotNull(surface); }
public void Test_MoveRover2(string size, string initialPosition, string directionList) { SurfaceHandler _surfaceHandler = new SurfaceHandler(); var surface = _surfaceHandler.CreateSurface(size); DeployRoverHandler deploy = new DeployRoverHandler(); var rover = deploy.DeployRover(initialPosition); Console.WriteLine("Rover Test", rover.Position.Position_X.ToString()); string directiveList = directionList; var directives = DirectiveHandler.DirectiveList(directiveList); foreach (var item in directives) { if (item == Domain.Enums.Directive.RotateRight) { RightDirectiveHandler.TurnRight(rover); } else if (item == Domain.Enums.Directive.MoveForward) { MoveDirectionHandler.Move(rover, surface); } else if (item == Domain.Enums.Directive.RotateLeft) { LeftDirectiveHandler.TurnLeft(rover); } } Assert.Equal(5, rover.Position.Position_X); Assert.Equal(1, rover.Position.Position_Y); Assert.Equal(Direction.E, rover.Position.Direction); }
static void Main(string[] args) { Console.WriteLine("Welcome on the Mars Rover Land Program"); Console.WriteLine("Please set the surface size Eg:3 5"); string surfaceSize = Console.ReadLine(); SurfaceHandler surface = new SurfaceHandler(); var plateau = surface.CreateSurface(surfaceSize); Console.WriteLine($"Surface width : {plateau.Width} and height : {plateau.Height}"); Dictionary <Domain.Rover, List <Domain.Enums.Directive> > roverList = new Dictionary <Domain.Rover, List <Domain.Enums.Directive> >(); while (true) { var(rover, directiveList) = AddRover(); roverList.Add(rover, (List <Domain.Enums.Directive>)directiveList); System.Console.WriteLine("Do you want to add new rover to plateau ? (Y/N)"); var answer = Console.ReadLine(); if (answer == "N") { MoveRover(roverList, plateau); break; } } }