public void Run() { CleanningProcess cleanningProcess = _reader.ReadAllCommands(); int placesClean = _robotCleanerServices.ExecuteClean(cleanningProcess); _view.WriteLine(string.Format(Resources.ResultLabel, placesClean)); }
public int ExecuteClean(CleanningProcess cleanningProcess) { GoTo(cleanningProcess.StartingCoordinate); foreach (var command in cleanningProcess.Commands) { this.MoveTowards(command.Direction, command.Steps); } return(_cleanOffices.Count); }
public CleanningProcess ReadAllCommands() { int amountOfCommands = this.ReadAmountOfCommands(); Coordinate startingCoordinate = this.ReadStartingCoordinate(); List <MoveCommand> commands = new List <MoveCommand>(); while (commands.Count < amountOfCommands) { commands.Add(this.ReadCommand()); } CleanningProcess cleanningProcess = new CleanningProcess(startingCoordinate, commands); return(cleanningProcess); }
public void ReadAllCommand_text_sequence_input_should_return_CleanningSession() { CommandReader test = new CommandReader(_mockView.Object, _mockRobotCleanerServices.Object); _mockView.SetupSequence(x => x.ReadLine()) .Returns("2") .Returns("10 22") .Returns("E 2") .Returns("N 1"); CleanningProcess result = test.ReadAllCommands(); Assert.AreEqual(2, result.Commands.Count); Assert.AreEqual(10, result.StartingCoordinate.X); Assert.AreEqual(22, result.StartingCoordinate.Y); Assert.AreEqual(Direction.E, result.Commands[0].Direction); Assert.AreEqual(2, result.Commands[0].Steps); Assert.AreEqual(Direction.N, result.Commands[1].Direction); Assert.AreEqual(1, result.Commands[1].Steps); }