static void Main() { IPlateau plateu = new Plateau("plateau", new Point(), new Point(5, 5)); ISender mediator = new RoverMediator(plateu); IRover rover1 = new Rover(plateu, new Point(1, 2), "rover1", Direction.North); IRover rover2 = new Rover(plateu, new Point(3, 3), "rover2", Direction.East); plateu.DeployRover(rover1); plateu.DeployRover(rover2); IEnumerable <ICommand> rover1Commands = CommandParser.CreateRoverCommandsFromText("LMLMLMLMM", rover1); IEnumerable <ICommand> rover2Commands = CommandParser.CreateRoverCommandsFromText("MMRMMRMRRM", rover2); //mediator.Send(rover1, rover1Commands); //mediator.Send(rover2, rover2Commands); IEnumerable <Task> deploys = new List <Task> { Task.Run(() => mediator.Send(rover1, rover1Commands)), Task.Run(() => mediator.Send(rover2, rover2Commands)) }; Task.WhenAll(deploys); System.Console.WriteLine("Test Input: \n5 5 \n1 2 N \nLMLMLMLMM \n3 3 E \nMMRMMRMRRM\n"); System.Console.WriteLine("Expected Output:\n1 3 N\n5 1 E\n"); System.Console.WriteLine(plateu.ToString()); System.Console.ReadLine(); }
static void Main(string[] args) { do { try { Console.Write("Enter the upper and lower boundaries (X Y) : "); Plateau p = new Plateau(Console.ReadLine()); do { try { Console.Write("Enter the deploy position of rover (X Y Direction) : "); var rover = p.DeployRover(Console.ReadLine()); Console.Write("Enter the series of instructions : "); p.Run(rover, Console.ReadLine()); } catch (Exception e) { Console.WriteLine(e.Message); } } while (true); } catch (Exception e) { Console.WriteLine(e.Message); } } while (true); Console.ReadKey(); }
public void NoRoverAtPoint() { var plateau = new Plateau(new Point(1, 1)); plateau.DeployRover(new Position(Point.Origin)); Assert.False(plateau.IsThereARoverAtPoint(new Point(1, 0))); }
public void RoverAtPoint() { var plateau = new Plateau(Point.Origin); plateau.DeployRover(new Position(Point.Origin)); Assert.True(plateau.IsThereARoverAtPoint(Point.Origin)); }
public void DeployRover_ShouldNotDeploy() { Mock <IRover> roverMock = new Mock <IRover>(); roverMock.SetupGet(c => c.Name).Returns(string.Empty); IPlateau plateau = new Plateau("plateau1", new Point(0, 0), new Point(5, 5)); Action deployAction = () => plateau.DeployRover(roverMock.Object); deployAction.Should().Throw <Exception>(); }
public void CheckPointIsEmpty_NotIncludedPoint_ShouldFalse() { IPlateau plateau = new Plateau("plateau", new Point(0, 0), new Point(5, 5)); plateau.DeployRover(new Rover(plateau, new Point(1, 1), "rover_1", Direction.East)); plateau.Name.Should().NotBeNullOrEmpty(); plateau.CheckPointIsEmpty(new Point(9, 0)).Should().BeFalse(); plateau.CheckPointIsEmpty(new Point(1, 1)).Should().BeFalse(); plateau.CheckPointIsEmpty(new Point(6, 5)).Should().BeFalse(); plateau.CheckPointIsEmpty(new Point(2, 7)).Should().BeFalse(); }
public void CheckPointIsEmpty_EmptyPlato_ShouldTrue() { IPlateau plateau = new Plateau("plateau", new Point(0, 0), new Point(5, 5)); plateau.DeployRover(new Rover(plateau, new Point(4, 3), "rover_1", Direction.East)); plateau.Name.Should().NotBeNullOrEmpty(); plateau.CheckPointIsEmpty(new Point(0, 0)).Should().BeTrue(); plateau.CheckPointIsEmpty(new Point(0, 1)).Should().BeTrue(); plateau.CheckPointIsEmpty(new Point(5, 5)).Should().BeTrue(); plateau.CheckPointIsEmpty(new Point(2, 4)).Should().BeTrue(); }
public void DeployRover_ShouldDeploy() { Mock <IRover> roverMock = new Mock <IRover>(); roverMock.SetupGet(c => c.Name).Returns("rover1"); IPlateau plateau = new Plateau("plateau1", new Point(0, 0), new Point(5, 5)); plateau.DeployRover(roverMock.Object); bool isRoverOn = plateau.IsRoverOn(roverMock.Object); isRoverOn.Should().BeTrue(); }