static void Main(string[] args) { Assembler.Errors.SetResource(Properties.Resources.errors); bool debug = false; string filename = ""; if (args.Length == 1) { filename = args[0]; } else if (args.Length == 2 && args[0] == "-d") { debug = true; filename = args[1]; } else { Usage(); System.Environment.Exit(1); } var parser = new Parser(); bool success = parser.ParseFile(filename); if (success) { Runtime.Debug = debug; Runtime.GetInstance().Run(); } }
public void TestValidPlaceCommandDirection(string data) { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = "PLACE 1,1," + data; o.Parse(command); Assert.AreEqual(data, o.DResult.ToString()); }
public void TestPlaceCommandWithInvalidFacing() { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = "PLACE 0,0,INVALID"; var expected = Simulator.CommandType.NOP; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestPlaceCommandWithWrongOrderParameters() { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = "PLACE 0,NORTH,0"; var expected = Simulator.CommandType.NOP; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestInvalidCommand() { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = "INVALID"; var expected = Simulator.CommandType.NOP; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestReportCommandBeforePlaceCommand() { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = "REPORT"; var expected = Simulator.CommandType.NOP; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestEmptyParse() { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = string.Empty; var expected = Simulator.CommandType.NOP; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestPlaceCommandCorrectCoordinates(int x, int y) { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = string.Format("PLACE {0},{1},NORTH", x, y); o.Parse(command); Assert.AreEqual(x, o.XResult); Assert.AreEqual(y, o.YResult); }
public void TestValidPlaceCommand(string data) { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = "PLACE " + data; var expected = Simulator.CommandType.PLACE; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestPlaceCommandWithIncorrectCoordinates(int x, int y) { var o = new Simulator.Parser(Substitute.For <IRobot>()); var command = string.Format("PLACE {0},{1},NORTH", x, y); var expected = Simulator.CommandType.NOP; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestReportCommandOnPlacedRobot() { var robot = Substitute.For <IRobot>(); robot.X.Returns(2); robot.Y.Returns(2); robot.FacingDirection.Returns(Direction.EAST); var o = new Simulator.Parser(robot); var command = "Report"; var expected = Simulator.CommandType.REPORT; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestMoveCommandToMakeRobotFall(int x, int y, Direction d) { var robot = Substitute.For <IRobot>(); robot.X.Returns(x); robot.Y.Returns(y); robot.FacingDirection.Returns(d); var o = new Simulator.Parser(robot); var command = "MOVE"; var expected = Simulator.CommandType.NOP; var actual = o.Parse(command); Assert.AreEqual(expected, actual); }
public void TestCreate() { var o = new Simulator.Parser(Substitute.For <IRobot>()); Assert.IsNotNull(o); }