The issue seems to be the use of [NSDistibutedNotificationCenter defaultCenter] since the test works fine if I change the notification center to [NSNotificationCenter defaultCenter].
Is observerMock supposed to work with distributed notifications, or am I doing something wrong?
This is my test:
- Code: Select all
NSNotificationCenter* center = [NSDistributedNotificationCenter defaultCenter];
id mockObserver = [OCMockObject observerMock];
[center addMockObserver:mockObserver name:@"foo" object:nil];
[[mockObserver expect] notificationWithName:@"foo" object:nil];
[center postNotificationName:@"foo" object:nil];
The error that I get is:
OCMockObserver: expected notification was not observed: <OCMObserverRecorder: 0x1336e900>