static void Main(string[] args) { string source = string.Empty; string result = string.Empty; TextFileHandler txtHandler = new TextFileHandler(); if (args.Length > 2 || args.Length < 2) { Console.WriteLine("Execution: program source.json result.json. \nPlease, specify two valid JSON files."); return; } source = txtHandler.read(args[0]); if (source == null) { Console.WriteLine("{0} cannot be read. Please, specify a valid source JSON file.", args[0]); } InputData id = InputData.parseToInputData(source); ProcessingControl pc = createRobot(id); // Execute robot pc.execProgram(id.commands); // Write output to disk Stats stats = pc.getStats(); txtHandler.Content = stats.outputToPrettyJSON(); txtHandler.write(args[1]); }
public void execProgram_advanceToColumnBackoff2_returnErrorFalse() { map = new OpMap(m, Direction.N, 2, 2); proc = new WithStrategy_2(motCtrl, map); Command[] cmds = new Command[] { Command.A }; proc.execProgram(cmds); Assert.IsFalse(proc.Error); Assert.AreEqual(map.Direction, Direction.N); Assert.AreEqual(map.XCoord, 3); Assert.AreEqual(map.YCoord, 0); }
public void execProgram_advanceToNullBackoff5_returnErrorFalse() { m[3, 3] = Map.Null; map = new OpMap(m, Direction.S, 3, 2); proc = new WithStrategy_5(motCtrl, map); Command[] cmds = new Command[] { Command.A }; proc.execProgram(cmds); Assert.IsFalse(proc.Error); Assert.AreEqual(map.Direction, Direction.N); Assert.AreEqual(map.XCoord, 3); Assert.AreEqual(map.YCoord, 0); }
public void init() { // Test_1 m = new Map[, ] { { Map.S, Map.S, Map.S, Map.S }, { Map.S, Map.S, Map.C, Map.S }, { Map.S, Map.S, Map.S, Map.S }, { Map.S, Map.Null, Map.S, Map.S }, }; map = new OpMap(m, Direction.N, 3, 0); motCtrl = new MotionControl(10); proc = new ProcessingControl(motCtrl); }
public void execProgram_Test1_returnResult() { map = new OpMap(m, Direction.N, 3, 0); motCtrl = new MotionControl(80); proc = new ProcessingControl(motCtrl); proc.LoadMap = map; Command[] cmds = new Command[] { Command.TL, Command.A, Command.C, Command.A, Command.C, Command.TR, Command.A, Command.C }; proc.execProgram(cmds); Assert.AreEqual(Direction.E, map.Direction); Assert.AreEqual(54, motCtrl.Battery); Assert.AreEqual(2, map.XCoord); Assert.AreEqual(0, map.YCoord); }
public void execProgram_Test2_returnResult() { // Test_1 m = new Map[, ] { { Map.S, Map.S, Map.S, Map.S }, { Map.S, Map.S, Map.C, Map.S }, { Map.S, Map.S, Map.S, Map.S }, { Map.S, Map.Null, Map.S, Map.S }, }; map = new OpMap(m, Direction.S, 3, 1); motCtrl = new MotionControl(1094); proc = new ProcessingControl(motCtrl); proc.LoadMap = map; Command[] cmds = new Command[] { Command.TR, Command.A, Command.C, Command.A, Command.C, Command.TR, Command.A, Command.C }; proc.execProgram(cmds); Assert.AreEqual(Direction.E, map.Direction); Assert.AreEqual(1040, motCtrl.Battery); Assert.AreEqual(3, map.XCoord); Assert.AreEqual(2, map.YCoord); }