Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Delphi Mock Framework and causing side effects

I am using the rather good Delphi Mocks Framework, and am trying to create a Mock of a class that contains a method that has 'side-effects', i.e. it is a read operation, and in the real-world implementation it sets the contents of a buffer, if the read is successful. So my question is, how do I mock that 'side-effect'?

like image 766
mmmm Avatar asked Dec 29 '25 20:12

mmmm


1 Answers

You can use the WillExecute method on the mock and pass in a delegate (see Delphi.Mocks.pas for it's signature) that does whatever you want.

like image 136
Stefan Glienke Avatar answered Dec 31 '25 11:12

Stefan Glienke