ios - How can I use OCMock objects with code that calls isKindOfClass? -


I want to test some code with OCMock

Inside code code of code I am providing code to [NSObject isKindOfClass] , such as:

  if ([object iskind of class: [fancy class class]]). However, when I made an osmoc-object-based duplicate like this:  
  duplicate = [OCMockObject mockForClass: [fancy class class] ];  

It looks like it does not pass the isKindOfClass exam.

Any suggestions? The general rule is that if you are calling isKindOfClass: and < You are not going to be a Plist class (for example), NSSTing or NSNumber), you are doing it wrong.

If the method relies on two or two different things, then it depends on what logic, dividing it into several ways, and checking each method separately. / P>

If the method is only one thing, but to interact with the object differently, depending on which class it is:

  1. Make a protocol ( The protocol in Obj-C is called "Interface" in some other O languages, such as Java.)
  2. Convert many sections to all protocols. If necessary, use the categories to add the necessary methods from outside.
  3. Make the method under test check to replace current isKindOfClass: instead of replacing the protocol.
  4. Use methods in the method protocol in the examination.

Comments