This question pertains to using the iPhone Simulator with Unit Tests. I have written a series of tests that test storing of our data, merged or not merged with data we can access from the user's contacts, depending on whether or not the contact exists. I would like a way to set the permissions such that I can test (A) when the user gives permission to access the contacts and (B) when the user denies access to the contacts. What I would like is a way, in Unit Tests only, to hard-code the permission value. I don't want to prompt for it, since that would block the unit test from running with the additional hardship that the permission remains set to that value forever.
So I am reaching out to the SO community to see who else might be testing their code's interaction with address book contacts by controlling the permissions in a Unit Test. Does anyone have a recipe which allows me test both sides of the user giving and denying access to the Address Book contacts?
I am using the XCTestCase parent class. I would be open to using something else if that helped solved this problem.
I have read through all the related SO questions and answers in this area. They are focused on helping people with writing the permission-asking routines and accessing the address book contacts in their application. I know how to do that part. I am specifically talking about how to fake the address book permissions in a unit test.