title: Unit Test CLLocationManager implementation
body: <p>I have a class named "<code>GeolocationManager</code>" that handles a <code>CLLocationManager</code> object and <code>delegate</code> responses.</p>
  
  <pre><code>- (void)getGeolocationForClient:(id&lt;GeolocationManagerDelegate&gt;)client
  {
      _delegate = client;
      _locationManager = [self createLocationManager];
      _locationManager.delegate = self;
      _locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
      [_locationManager startUpdatingLocation];
  }
  
  - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
  {
     // do some stuff
  }
  </code></pre>
  
  <p>createLocationManager is a public method ready to be stubbed</p>
  
  <pre><code>- (CLLocationManager *)createLocationManager
  {
      return [[CLLocationManager alloc] init];
  }
  </code></pre>
  
  <p>What I want to achieve is to test that when user denies being geolocated the <code>CLLocationManagerDelegate</code> method <code>locationManager:didFailWithError:</code> is being called on my <code>GeolocationManager</code> object.</p>
  
  <p>My test method below does not seem to be working</p>
  
  <pre><code>- (void)testOnUserDenial
  {
      GeolocationManager *geolocationManager = [[GeolocationManager alloc] init];
      id geolocationManagerTest = [OCMockObject partialMockForObject:geolocationManager];
  
      CLLocationManager *locationManager = [[CLLocationManager alloc] init];
      id locationManagerTest = [OCMockObject partialMockForObject:locationManager];
  
      [[[locationManagerTest stub] andReturnValue:@(kCLAuthorizationStatusDenied)] authorizationStatus];
      [[[geolocationManagerTest stub] andReturn:locationManagerTest] createLocationManager];
  
      [[geolocationManagerTest expect] locationManager:[OCMArg any] didFailWithError:[OCMArg any]];
  
      [geolocationManagerTest getGeolocationForClient:[OCMArg any]];
  
      [geolocationManagerTest verify];
  }
  </code></pre>
  
  <blockquote>
    <p>Name: NSInternalInconsistencyException    File: Unknown   Line: Unknown
      Reason: OCPartialMockObject[GeolocationManager]: expected method was
    not invoked: locationManager:OCPartialMockObject[CLLocationManager]
    didFailWithError:</p>
  </blockquote>