3

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'?

Guillem Vicens
  • 3,936
  • 30
  • 44
mmmm
  • 2,431
  • 2
  • 35
  • 56

1 Answers1

3

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.

Stefan Glienke
  • 20,860
  • 2
  • 48
  • 102
  • Thanks, I think I was trying to do too much as once, and seem to have an issue when objects pass parameters to constructors. – mmmm May 28 '12 at 20:35