You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recently upated the version of Delphi-Mocks we where using and with this version it looks like we can not define differen behaviour for overloaded functions.
IMockIntf = interface(IInvokable)
['{E473945B-D350-4535-A981-B66A5B58DA21}']
function Test(const Arg1: string): TArray<string>; overload;
function Test(const Arg1, Arg2: string): TArray<string>; overload;
function Test(const Arg1, Arg2, Arg3: string): TArray<string>; overload;
end;
Given this interface it was possible (and needed) to define a return value for alle 3 functions separatly.
procedure TMyTestObject.Test1;
begin
var x := FMock.Instance.Test('A');
Assert.AreEqual('Test1', x);
end;
procedure TMyTestObject.Test2;
begin
var x := FMock.Instance.Test('A', 'B');
Assert.AreEqual('Test2', x);
end;
procedure TMyTestObject.Test3;
begin
var x := FMock.Instance.Test('A', 'B', 'C');
Assert.AreEqual('Test3', x);
end;
Unfortenatly with the latest version this is not working anymore. I looks like the Mock sees the Test functions as one and will not allow this:
EMockSetupException with message '[IMockIntf] already defines Will Return When for method [Test]'
If I use AllowRedefineBehaviorDefinitions := True I can define the behaviour, but than the function with 2 parameters returns the behaviour with 3 parameter 'Test3' and the function with 3 parameter raises an Access violation at address 00000000.
I used the latest version in combination with Delphi 11.3.
The text was updated successfully, but these errors were encountered:
We recently upated the version of Delphi-Mocks we where using and with this version it looks like we can not define differen behaviour for overloaded functions.
Given this interface it was possible (and needed) to define a return value for alle 3 functions separatly.
And than test the behaviour
Unfortenatly with the latest version this is not working anymore. I looks like the Mock sees the Test functions as one and will not allow this:
If I use AllowRedefineBehaviorDefinitions := True I can define the behaviour, but than the function with 2 parameters returns the behaviour with 3 parameter 'Test3' and the function with 3 parameter raises an Access violation at address 00000000.
I used the latest version in combination with Delphi 11.3.
The text was updated successfully, but these errors were encountered: