#1 2017-08-15 10:31:36

willo
Member
From: Cape Town, South Africa
Registered: 2014-11-15
Posts: 67
Website

Stubbing a method that returns an interface

Hi guys,

We're trying to stub an interface that contains a method that returns an interface. Mormot complains with:
blah : blah parameter should be declared as const
when we try to register the interface.

Looking at the code mormot.pas(54472) we get:

      if Kind=mkFunction then
        with Args[n] do begin
          ParamName := @CONST_PSEUDO_RESULT_NAME;
          ValueDirection := smdResult;
          SetFromRTTI(PB);
        end;

This effectively asks the method to verify the result type as if it were a parameter. But the verification requires an Interface type to be const.

Is this a bug or by design?

Offline

#2 2017-08-16 06:46:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Stubbing a method that returns an interface

This is as expected, in the current state of the framework.
Interfaces parameters can't be stubbed by the framework, currently.
They are used for asynchronous callbacks, in SOA interface-based services, but not handled yet by TInterfaceStub/TInterfaceMock.

In fact, the mocking feature uses JSON internally for the tracking/validation purposes, so expects the data to be serialized in a stateless representation.
How do you expect to define the class instance returned by the mocked interface?
Define a mocked interface?
Then it won't be representable as JSON anymore.

Offline

Board footer

Powered by FluxBB