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
vincentparrett edited this page Sep 18, 2011
·
11 revisions
##Delphi-Mocks
Delphi-Mocks is simple mocking framework for Delphi. It's intended to be used in conjunction with unit testing. The api is fluent where possible, and strongly typed where possible.
###RTTI on interfaces
Delph-Mocks currently only supports mocking interfaces, and is only supported in Delphi XE2. An interface must have Runtime Type Information (RTTI), to enable RTTI on an interface, add the {$M+} compiler directive before it.
{$M+}
IFoo = interface
procedure Bar;
end;
Creating the Mock
We make extensive use of Generics in the framework. To create the mock, we use the TInterfaceMock.Create class function,
procedure Test;
var
mock : TInterfaceMock<IFoo>; //our mock object
begin
//Create our mock
mock := TInterfaceMock<IFoo>.Create;
...
end;