In the sample project, Mark DiFranco creates a class to determine if the current speed has exceeded a specified value. He applies the concepts of single responsibility and dependency inversion to keep the class small, and independent of other classes.
- [Instructor] The last class we need to make…is a class to check the current speed.…Let's add one more new file,…and we'll call it SPDLocationSpeedChecker.…Once again, we'll define a protocol for this class.…Below the protocol,…we can implement the concrete class…called SPDDefaultLocationSpeedChecker,…and have an extension…so that this class conforms to our protocol.…
Just like our speedProvider,…our speedChecker is going to use the locationProvider…to get its location.…Let's add a property, just like before.…We'll update the initializer…to take in the property as a parameter,…and we can set the property on our selfs.…
We also want to make sure…that we add our self as a consumer of locations.…This will then prompt us to conform…to the locationConsumer protocol,…so we'll add an extension…at the bottom of our file to do that.…Remember, the only method is the consumeLocation method.…Again, we're getting a compiler error for the CLLocation,…so we'll import CoreLocation at the top.…
Let's take a look a the public protocol…
- Why write unit tests?
- What is dependency injection?
- Using protocols to help with tests
- Handling external dependencies
- Anatomy of a test case
- Writing tests
- Analyzing code coverage
- Visualizing test results
- Writing and extending UI tests
Skill Level Intermediate
Core Data for iOS and macOS Enterprise Developerswith Jon Bott1h 46m Intermediate
Learning Server-Side Swift with Vaporwith Ron Buencamino1h 30m Intermediate
1. Dependency Injection
2. Using Protocols
3. Writing Tests
4. UI Tests
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.