With PascalMock how do I mock a method with an untyped out parameter and an open array parameter?

Posted by Oliver Giesen on Stack Overflow See other posts from Stack Overflow or by Oliver Giesen
Published on 2010-05-20T14:30:24Z Indexed on 2010/05/20 15:30 UTC
Read the original article Hit count: 350

I'm currently in the process of getting started with unit testing and mocking for good and I stumbled over the following method that I can't seem to fabricate a working mock implementation for:

function GetInstance(const AIID: TGUID; 
                       out AInstance; 
                     const AArgs: array of const; 
                     const AContextID: TImplContextID = CID_DEFAULT): Boolean;

(TImplContextID is just an alias for Integer)

I thought it would have to look something like this:

function TImplementationProviderMock.GetInstance(
  const AIID: TGUID;
    out AInstance;
  const AArgs: array of const;
  const AContextID: TImplContextID): Boolean;
begin
  Result := AddCall('GetInstance')
           .WithParams([@AIID, AContextID])
           .ReturnsOutParams([AInstance])
           .ReturnValue;
end;

But the compiler complains about the .ReturnsOutParams([AInstance]) saying "Bad argument type in variable type array constructor.". Also I haven't found a way to specify the open array parameter AArgs at all.

Also, is using the @-notation for the TGUID-typed parameter the right way to go?

Is it possible to mock this method with the current version of PascalMock at all?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about pascalmock