by erik » 17 Dec 2009, 05:13
I can't verify this right now but it is likely that the notifications to the distributed notification centre are delivered asynchronously, ie. the notification will not be delivered during the call to postNotificationName: but at some later point; in this test case likely after the verify.
In a Cocoa application there is a way to yield to the run loop event processing but I doubt this'll work in the unit test rig. Alternatively, there might be a way to force synchronous posting of the notification. Maybe you could inject the notification centre into the object that posts the notification, then during the tests you could use a normal centre with synchronous delivery and in the real app you could use the distributed one.
I can't verify this right now but it is likely that the notifications to the distributed notification centre are delivered asynchronously, ie. the notification will not be delivered during the call to postNotificationName: but at some later point; in this test case likely after the verify.
In a Cocoa application there is a way to yield to the run loop event processing but I doubt this'll work in the unit test rig. Alternatively, there might be a way to force synchronous posting of the notification. Maybe you could inject the notification centre into the object that posts the notification, then during the tests you could use a normal centre with synchronous delivery and in the real app you could use the distributed one.