public void CommandMove_FacingEastAndAtFarRightOfGrid_ThrowsException() { // arrange IGrid grid = new Grid(5, 5); IRobot robot = new Robot(4, 0, OrientationEnum.East, grid); grid.Add(robot); // act robot.CommandMove(); }
public void CommandMove_FacingNorthAndAtTopOfGrid_ThrowsException() { // arrange IGrid grid = new Grid(5,5); IRobot robot = new Robot(0, 4, OrientationEnum.North, fiveByFiveGrid); grid.Add(robot); // act robot.CommandMove(); }
public void CommandMove_FacingNorth_IncrementY() { // arrange IRobot robot = new Robot(0, 0, OrientationEnum.North, fiveByFiveGrid); // act robot.CommandMove(); // assert Assert.That(robot.Y, Is.EqualTo(1)); Assert.That(robot.X, Is.EqualTo(0)); }
public void CommandLeft_ResultsInCorrectOrientation(OrientationEnum start, OrientationEnum expectedResult) { // arrange IRobot robot = new Robot(0, 0, start, fiveByFiveGrid); // act robot.CommandLeft(); // assert Assert.That(robot.Orientation, Is.EqualTo(expectedResult), string.Format("left rotation from {0} to {1} failed", start, expectedResult)); Console.WriteLine(string.Format("left rotation from {0} to {1} succeeded", start, expectedResult)); }
public void ExecuteInstructions_RobotEndsUpWhereItShould(string instructions, int expectedX, int expectedY, OrientationEnum expectedOrientation) { // arrange IGrid grid = new Grid(10,10); IRobotCommandMarshaller commandMarshaller = new RobotCommandMarshaller(); IRobot robot = new Robot(0,0,OrientationEnum.North, grid, commandMarshaller); // act robot.ExecuteInstructions(instructions); // assert Assert.That(robot.X, Is.EqualTo(expectedX)); Assert.That(robot.Y, Is.EqualTo(expectedY)); Assert.That(robot.Orientation, Is.EqualTo(expectedOrientation)); }
private static IRobot InitialiseRobot() { IRobot robot=null; Exception e; do { try { robot = new Robot(Console.ReadLine(), _grid); e = null; } catch (Exception exception) { Console.WriteLine(exception.Message); e = exception; } } while (e != null); return robot; }
public void CommandMove_FacingSouthAndAtBottomOfGrid_ThrowsException() { // arrange IGrid grid = new Grid(5, 5); IRobot robot = new Robot(0, 0, OrientationEnum.South, grid); grid.Add(robot); // act robot.CommandMove(); }
public void Ctor_CanInitialiseFromString(string setupString, int expectedX, int expectedY, OrientationEnum expectedOrientation) { // act IRobot robot = new Robot(setupString, fiveByFiveGrid); //Assert Assert.That(robot.X, Is.EqualTo(expectedX)); Assert.That(robot.Y, Is.EqualTo(expectedY)); Assert.That(robot.Orientation, Is.EqualTo(expectedOrientation)); }
public void Command_ResultsInCorrectOrientation(CommandTestCaseData testCase) { // arrange IRobot robot = new Robot(0, 0, testCase.StartOrientation, fiveByFiveGrid); // act testCase.Command.Invoke(robot); // assert Assert.That(robot.Orientation, Is.EqualTo(testCase.ExpectedOrientation)); }
public void CommandMove_FacingWest_DecrementX() { // arrange IRobot robot = new Robot(1, 1, OrientationEnum.West, fiveByFiveGrid); // act robot.CommandMove(); // assert Assert.That(robot.X, Is.EqualTo(0)); Assert.That(robot.Y, Is.EqualTo(1)); }