/Delphi.Mocks.When.pas
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 26unit Delphi.Mocks.When; 27 28interface 29 30uses 31 Delphi.Mocks, 32 Delphi.Mocks.InterfaceProxy; 33 34type 35 TWhen<T> = class(TInterfacedObject,IWhen<T>) 36 private 37 FProxy : T; 38 protected 39 function When : T; 40 public 41 constructor Create(const AProxy : T); 42 destructor Destroy;override; 43 end; 44 45implementation 46 47uses 48 SysUtils; 49 50{ TWhen<T> } 51 52constructor TWhen<T>.Create(const AProxy: T); 53begin 54 FProxy := AProxy; 55end; 56 57destructor TWhen<T>.Destroy; 58begin 59 FProxy := Default(T); 60 inherited; 61end; 62 63function TWhen<T>.When: T; 64begin 65 result := FProxy; 66end; 67 68end.