2015-02-25 18 views

risposta

9

Si prega di vedere la prima di queste lettere http://ocmock.org/reference/#advanced-topics

Nota che reject a questo punto nel tempo richiede la sintassi vecchio stile e deve essere chiamato prima il metodo può essere invocato, vale a dire.

// first set up the mock 
[[mock reject] methodThatShouldNotBeCalled] 
// then call method that should not result in the call 

Per uno sguardo su ciò che è previsto, vedere https://github.com/erikdoe/ocmock/issues/109

+0

Grazie per un bell'attrezzo Erik. –

0

ho fallito miseramente ad ottenere il rifiutare metodo a lavorare così la mia soluzione era quella di stub semplicemente il metodo di-non-a-BE- chiamato (notifyChange: nell'esempio seguente) con il lancio di un'eccezione ogni volta che viene chiamato.

// Set up the mock. 
id<TSModelObserver> observer = OCMProtocolMock(@protocol(TSModelObserver)); 

// Stub the forbidden method call with throwing an exception.  
[OCMStub([observer notifyChange:model]) andThrow:[NSException new]]; 
1

Come ho risposto here, a partire dalla versione 3.3 OCMock ha OCMReject macro.

Problemi correlati