دلفي تعليم
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

serial driver

اذهب الى الأسفل

serial driver   Empty serial driver

مُساهمة  spider-dz 31/5/2015, 7:30 pm

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function TestDouble: Double;
{ Private declarations }
public
{ Public declarations }
end;

ITest = interface(IInvokable)
['{DE3ACD58-A748-4528-A2A6-13C7A9247DB2}']
function GetDate: TDateTime;
property Date: TDateTime read GetDate;
end;

var
Form1: TForm1;

implementation

uses
Delphi.Mocks;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
mock: TMock<ITest>;
test: ITest;
begin
mock := TMock<ITest>.Create;
mock.Setup.WillReturn(Date).When.GetDate;
Button1.Tag := Trunc(TestDouble);
test := mock;
Button1.Caption := DateToStr(test.GetDate);
end;

function TForm1.TestDouble: Double;
begin
Result := 123;
end;

spider-dz
زائر


الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة


 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى