Skip to content

Question: How to mock a method that passes a parameter by reference? #88

@rpottsoh

Description

@rpottsoh

I have a method (function) that has two arguments and returns an integer. The first argument is passed by value and the second by reference (var). I would like to mock what this method should pass back on on the second argument. First, the closest thing I can see to accomplish this is to use WillExecute. However this only passes my method's arguments in as const. I am setting the result of my TExecuteFunc equal to args[0]. I would like to set args[1] equal to some value.

How to mock, or stub, a method that has one or more arguments that are passed by reference? I am wanting to test the argument that is passed by reference. The CUT has a method that that passes an argument by reference.

MockDap.Setup.WillExecute(function (const args : TArray<TValue>; const ReturnType : TRttiType) : TValue begin result := args[0]; args[1] := Expected; end).When.GetDAPData(TheLength, Actual);

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions