Domanda

My MessageSerializer class has a method whose signature looks like this:

- (Message *)deserialize:(const void *)buffer length:(NSUInteger)length;

Can I use OCMockito to stub it? Where serializer is my mock serializer, the compiler approves of all these following forms in my test method:

[given([serializer deserialize:[data bytes] length:[data length]]) willReturn:message];
[given([serializer deserialize:(__bridge const void *)anything() length:[data length]]) willReturn:message];
[given([serializer deserialize: CFBridgingRetain(anything()) length:[data length]]) willReturn:message];

... but none of them cause the mock to return "message" to the class under test when deserialize:length: is called.

È stato utile?

Soluzione

OCMockito doesn't support const void * parameters at this time. I'd recommend making a hand-rolled stub.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top