public void Rotate_ShouldDoNothingBeforeRobotIsPlaced(int spin) { //Arrange var mockTable = new Mock <RectangularTable>(1, 1); IRobot robot = new ToyRobotLibrary.Robot.Robot(mockTable.Object); var orientationField = robot.GetType().GetField("_orientation", BindingFlags.NonPublic | BindingFlags.Instance); //Act robot.Rotate((SpinDirection)spin); //Assert Assert.Null(orientationField.GetValue(robot)); }
public void Rotate_ShouldSucceed_WithSingleSpin(int startingOrientation, int spin, int expectedOrientation) { //Arrange var mockTable = new Mock <RectangularTable>(1, 1); IRobot robot = new ToyRobotLibrary.Robot.Robot(mockTable.Object); var positionField = robot.GetType().GetField("_position", BindingFlags.NonPublic | BindingFlags.Instance); var orientationField = robot.GetType().GetField("_orientation", BindingFlags.NonPublic | BindingFlags.Instance); var isPlacedProperty = robot.GetType().GetProperty("IsPlaced", BindingFlags.Public | BindingFlags.Instance); positionField.SetValue(robot, new Position { x = 0, y = 0 }); orientationField.SetValue(robot, (Orientation)startingOrientation); isPlacedProperty.SetValue(robot, true); //Act robot.Rotate((SpinDirection)spin); //Assert Assert.Equal((Orientation)expectedOrientation, orientationField.GetValue(robot)); }