 
 }
 
+extension XCTest {
+
+  func XCTAssertThrow<R, E where E: ErrorType, E: Equatable>(expectedError: E, @autoclosure _ closure: () throws -> R) -> () {
+    do {
+      try closure()
+      XCTFail("Expected error \"\(expectedError)\", " + "but closure succeeded.")
+    } catch let error as E {
+      XCTAssertEqual(error, expectedError,
+          "Catched error is from expected type, but not the expected case.")
+    } catch {
+      XCTFail("Catched error \"\(error)\", "
+          + "but not the expected error "
+          + "\"\(expectedError)\".")
+    }
+  }
+}
 
 
+

  }

  func givenDirection() -> Direction {
    return North(planet: Planet())
  }

  func initialPositionLookingAt(direction: Direction) -> Position {
    return Position(point: initialPoint, direction: direction)
  }

  func givenMarsRoverAt(position: Position) -> MarsRover {
    return MarsRover(initialPosition: position)
  }

  func givenMarsRoverAtInitialPositionWith(action: Action) -> MarsRover {

    XCTAssertEqual(position, initialPoint)
  }

  func testExecuteCommands_whenCommandCanExecute() throws {
    let action = givenActionSpy()
    let rover = givenMarsRoverAtInitialPositionWith(action)

    let commandsInput = "ab"
    try rover.execute(commandsInput)

    XCTAssertTrue(action.executeCalled)
    XCTAssertEqual(commandsInput.characters.count, action.executeTimes)
  }

  func testThrowUnkownCommandError_whenCanNotExecuteCommand() throws {
    let action = givenCanNotExecuteAction()
    let rover = givenMarsRoverAtInitialPositionWith(action)

    let unkownCommand = "u"
    XCTAssertThrow(RoverError.UnknownCommand(command: unkownCommand), try rover.execute(unkownCommand))
  }

  func givenCanNotExecuteAction() -> Action {
