I want to test that the values i insert in a database are sent back to the delegate of my class.
I tried to mock the delegate and expect the array i used to populate the database. It fails because the 2 NSArray have the same content but are different objects.
I've tried implementing isequal and hash methods on my model whithout success.
Here is the error log :
'OCMockObject[NewsListViewController]: unexpected method invoked: service:<RSSService-0x4c25b90-324400011.636966: 0x4c25b90> didFinishParsingRSSWithItems:(
description102362,
description102362,
description102362,
description102362,
description102362
)
expected: service:<OCMAnyConstraint: 0x4c10f30> didFinishParsingRSSWithItems:(
description102362,
description102362,
description102362,
description102362,
description102362
)'
How can i do that ?
Here is my test :
- (void) testServiceShouldNotLoadArticlesFromRSSFeedIfArticlesInDatabase {
NSArray *fakeArticles = [TestUtils createArticles:5];
[[DatabaseManager sharedManager] saveArticles:fakeArticles];
RSSService *mockService = [OCMockObject partialMockForObject:service];
id mockDelegate = [OCMockObject mockForClass:NewsListViewController.class];
[[mockDelegate expect] service:[OCMArg any] didFinishParsingRSSWithItems:fakeArticles];
mockService.delegate = mockDelegate;
[mockService loadAllArticles];
[mockService verify];
[mockDelegate verify];
}
and here is the method i'm testing :
- (void) loadAllArticles {
NSArray *articles = [self articlesFromDatabase];
[self.delegate service:self didFinishParsingRSSWithItems:articles];
}
Thanks for your help, Vincent