Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy for constructor with params #83

Merged

Conversation

ASiwon
Copy link
Contributor

@ASiwon ASiwon commented Nov 16, 2015

here is pull request for the issue 24 (#24)

@ASiwon
Copy link
Contributor Author

ASiwon commented Nov 16, 2015

I can't add comment to the issue #24 (probably because it is closed) so I wrote description here.

After 19 months I found the next use case, where I need mock with parametrized constructor. So now I made changes in Delphi.Mocks source code. The changes are available in pull request so now you can have a review.
I have change my concept. Array with params is not used. I have used reference to anonymous function which return instance of mocked object. So creating mock for object looks for example like:

var
  lMock: TMock<TComponent>;
begin
  lMock: TMock<TComponent>.Create(function : TComponent
    begin
      Result := TComponent.Create(nil);
    end);
end;

I think using anonymous method in this case give better control of types while compile time. (Compiler cannot validate compatibility of the array of parameters with parameters of constructor)

@staticcat
Copy link
Contributor

Looks good to me, happy to merge. All previous functionality is in place and works. Anyone else care to weigh in?

staticcat added a commit that referenced this pull request Nov 26, 2015
@staticcat staticcat merged commit b742e3e into VSoftTechnologies:master Nov 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants