Adding a coordinate property

To drive the addition of a coordinate property, we need a failing test. Add the following test to LocationTests:

func test_Init_SetsCoordinate() { 
  let coordinate =     CLLocationCoordinate2D(latitude: 1,                           longitude: 2) 
   

  let location = Location(name: "",                           coordinate: coordinate) 
   

  XCTAssertEqual(location.coordinate?.latitude,                   coordinate.latitude)  XCTAssertEqual(location.coordinate?.longitude,                 coordinate.longitude) 
} 

First, we create a coordinate and use it to create an instance of Location. Then, we assert that the latitude and longitude of the location coordinates are set to the correct values. We use the values 1 and 2 in the initializer of CLLocationCoordinate2D, because it also has an initializer that takes no arguments ...

Get Test-Driven iOS Development with Swift 4 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.