public void GetPosition_ShouldReturnNullIfNotPlaced() { //Arrange var mockTable = new Mock <RectangularTable>(5, 5); IRobot robot = new ToyRobotLibrary.Robot.Robot(mockTable.Object); //Act var result = robot.GetPosition(); //Assert Assert.Null(result); }
public void GetPosition_ShouldReturnPosition(int x, int y) { //Arrange var mockTable = new Mock <RectangularTable>(5, 5); IRobot robot = new ToyRobotLibrary.Robot.Robot(mockTable.Object); var positionField = robot.GetType().GetField("_position", BindingFlags.NonPublic | BindingFlags.Instance); var isPlacedProperty = robot.GetType().GetProperty("IsPlaced", BindingFlags.Public | BindingFlags.Instance); positionField.SetValue(robot, new Position(x, y)); isPlacedProperty.SetValue(robot, true); //Act var result = robot.GetPosition(); //Assert Assert.IsType <Position>(result); Assert.Equal(x, result.x); Assert.Equal(y, result.y); }