objective c - Cant stub a method using OCMock -


i using ocmock on objc project.

i have following code:

 db_account *lena = [[db_account alloc] init];     lena.nicename = @"lena";     lena.userid = @"lena";     id mockstoragemanager = ocmclassmock([v4_storagemanager class]);      [[[mockstoragemanager stub] andreturn:lena] getaccountbydbid:@1];      id mockdbnotificationmanager = ocmclassmock([dbnotificationmanager class]);      id partialv4dbnotificationmanagermock = ocmpartialmock([v4_dbnotificationmanager manager]);      [[[mockdbnotificationmanager stub] andreturn:(notificationpolicy *)[notificationpolicy never]] getnotificationpolicy];      [[[partialv4dbnotificationmanagermock stub] andreturn:mockdbnotificationmanager] dbnotificationmanager];     bool shouldshow = [[v4_dbnotificationmanager manager] showonloginexpired:lena];      assertthatbool(shouldshow,is(isfalse())); 

this code fails compile on following line:

[[[mockdbnotificationmanager stub] andreturn:(notificationpolicy *)[notificationpolicy never]] getnotificationpolicy]; 

with error:

error:(95, 5) multiple methods named 'getnotificationpolicy' found mismatched result, parameter type or attributes 

this method returns object of type notificationpolicy *, no other class implements or declares method name.

what wrong?

i had solve problem

 [(dbnotificationmanager*)[[mockdbnotificationmanager stub]  andreturn:[notificationpolicy never]] getnotificationpolicy]; 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -