public bool Process(string command) { var result = string.Empty; try { if (!new ValidateCommandLine(Constant.CheckRobotRegex).Validate(command)) { return false; } string[] words = command.Split(' '); uint xAxis = Convert.ToUInt32(words[0]); uint yAxis = Convert.ToUInt32(words[1]); Direction direction = Helper.ConvertToDirection(words[2]); bool robotCreated = new RobotWars().EnterArena(this.context.Arena, xAxis, yAxis, direction); result = String.Format("Robot creation {0}", robotCreated ? "succesful" : "failed"); } catch (Exception) { result = "Robot creation failed"; throw; } finally { Console.WriteLine(result); } return true; }
public bool Process(string command) { var result = string.Empty; try { if (!new ValidateCommandLine(Constant.CheckRobotRegex).Validate(command)) { return(false); } string[] words = command.Split(' '); uint xAxis = Convert.ToUInt32(words[0]); uint yAxis = Convert.ToUInt32(words[1]); Direction direction = Helper.ConvertToDirection(words[2]); bool robotCreated = new RobotWars().EnterArena(this.context.Arena, xAxis, yAxis, direction); result = String.Format("Robot creation {0}", robotCreated ? "succesful" : "failed"); } catch (Exception) { result = "Robot creation failed"; throw; } finally { Console.WriteLine(result); } return(true); }
public virtual void Setup() { this.arenaStub = MockRepository.GenerateStub <IArena>(); this.arenaStub.Stub(c => c.Width).Return(coordinate); this.arenaStub.Stub(c => c.Height).Return(coordinate); this.robotStub = MockRepository.GenerateStub <IRobotWars>(); this.robotStub.Stub(c => c.Direction).Return(Direction.South); this.contextStub = MockRepository.GenerateStub <IContext>(); this.robot = new RobotWars(); }