/Delphi.Mocks.When.pas

https://github.com/dougcunha/Delphi-Mocks · Pascal · 68 lines · 32 code · 11 blank · 25 comment · 0 complexity · 474cbf8bd8a86a0b1edefd42f2f13d9e MD5 · raw file

  1. {***************************************************************************}
  2. { }
  3. { Delphi.Mocks }
  4. { }
  5. { Copyright (C) 2011 Vincent Parrett }
  6. { }
  7. { http://www.finalbuilder.com }
  8. { }
  9. { }
  10. {***************************************************************************}
  11. { }
  12. { Licensed under the Apache License, Version 2.0 (the "License"); }
  13. { you may not use this file except in compliance with the License. }
  14. { You may obtain a copy of the License at }
  15. { }
  16. { http://www.apache.org/licenses/LICENSE-2.0 }
  17. { }
  18. { Unless required by applicable law or agreed to in writing, software }
  19. { distributed under the License is distributed on an "AS IS" BASIS, }
  20. { WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
  21. { See the License for the specific language governing permissions and }
  22. { limitations under the License. }
  23. { }
  24. {***************************************************************************}
  25. unit Delphi.Mocks.When;
  26. interface
  27. uses
  28. Delphi.Mocks,
  29. Delphi.Mocks.InterfaceProxy;
  30. type
  31. TWhen<T> = class(TInterfacedObject,IWhen<T>)
  32. private
  33. FProxy : T;
  34. protected
  35. function When : T;
  36. public
  37. constructor Create(const AProxy : T);
  38. destructor Destroy;override;
  39. end;
  40. implementation
  41. uses
  42. SysUtils;
  43. { TWhen<T> }
  44. constructor TWhen<T>.Create(const AProxy: T);
  45. begin
  46. FProxy := AProxy;
  47. end;
  48. destructor TWhen<T>.Destroy;
  49. begin
  50. FProxy := Default(T);
  51. inherited;
  52. end;
  53. function TWhen<T>.When: T;
  54. begin
  55. result := FProxy;
  56. end;
  57. end.