With PascalMock how do I mock a method with an untyped out parameter and an open array parameter?
- by Oliver Giesen
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?