Skip to content

Commit

Permalink
Repo reorg, added dpm spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentparrett committed Apr 10, 2020
1 parent e9099dc commit 6a49b49
Show file tree
Hide file tree
Showing 31 changed files with 1,760 additions and 1,724 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
###################
/Win32
/Win64
/Tests/Win32
/Tests/Win64
/Examples/Win32
/Examples/Win64

Build/TestAndBuild.fb7lck
*.fbl7
Expand Down
1 change: 0 additions & 1 deletion DUnitXML
Submodule DUnitXML deleted from e446bf
94 changes: 94 additions & 0 deletions Delphi.Mocks.dspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"metadata": {
"id": "Delphi.Mocks",
"version": "0.0.2",
"description": "Simple mocking framework for Delphi XE2 or later.",
"authors": "Vincent Parrett",
"projectUrl": "https://github.com/VSoftTechnologies/Delphi-Mocks",
"license": "Apache-2.0",
"copyright": "Vincent Parrett and contributors",
"tags": "mocking unittesting"
},
"targetPlatforms": [
{
"compiler": "XE2",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "XE3",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "XE4",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "XE5",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "XE6",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "XE7",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "XE8",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "10.0",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "10.1",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "10.2",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "10.3",
"platforms": "Win32, Win64",
"template": "default"
},
{
"compiler": "10.4",
"platforms": "Win32, Win64",
"template": "default"
}
],
"templates": [
{
"name": "default",
"source": [
{
"src": "Source\\*.pas",
"dest": "src"
},
{
"src": "Source\\*.inc",
"dest": "src"
}
],
"searchPaths": [
{
"path": "src"
}
]
}
]
}
48 changes: 0 additions & 48 deletions DelphiMocks.groupproj

This file was deleted.

28 changes: 28 additions & 0 deletions Examples/Sample1.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
program Sample1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
SysUtils,
Sample1Main in 'Sample1Main.pas',
Delphi.Mocks.Example.ProjectSaveCheckVisitor in 'Delphi.Mocks.Example.ProjectSaveCheckVisitor.pas',
Delphi.Mocks.Examples.Factory in 'Delphi.Mocks.Examples.Factory.pas',
Delphi.Mocks.Examples.Implement in 'Delphi.Mocks.Examples.Implement.pas',
Delphi.Mocks.Examples.Interfaces in 'Delphi.Mocks.Examples.Interfaces.pas';

begin
try
TesTObjectMock;
Writeln('--------------');
Test;
ReadLn;
except
on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
ReadLn;
end;
end;
end.
44 changes: 17 additions & 27 deletions Sample1.dproj → Examples/Sample1.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<DCC_UnitSearchPath>$(DUNITX);$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<DCC_UnitSearchPath>..\Source;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<SanitizedProjectName>Sample1</SanitizedProjectName>
<DCC_DUPLICATE_CTOR_DTOR>false</DCC_DUPLICATE_CTOR_DTOR>
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.2.3.4;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0</VerInfo_Keys>
Expand Down Expand Up @@ -125,29 +125,11 @@
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="Delphi.Mocks.AutoMock.pas"/>
<DCCReference Include="Delphi.Mocks.Behavior.pas"/>
<DCCReference Include="Delphi.Mocks.Expectation.pas"/>
<DCCReference Include="Delphi.Mocks.Helpers.pas"/>
<DCCReference Include="Delphi.Mocks.Interfaces.pas"/>
<DCCReference Include="Delphi.Mocks.MethodData.pas"/>
<DCCReference Include="Delphi.Mocks.ObjectProxy.pas"/>
<DCCReference Include="Delphi.Mocks.ParamMatcher.pas"/>
<DCCReference Include="Delphi.Mocks.pas"/>
<DCCReference Include="Delphi.Mocks.Proxy.pas"/>
<DCCReference Include="Delphi.Mocks.Proxy.TypeInfo.pas"/>
<DCCReference Include="Delphi.Mocks.ReturnTypePatch.pas"/>
<DCCReference Include="Delphi.Mocks.Utils.pas"/>
<DCCReference Include="Delphi.Mocks.Validation.pas"/>
<DCCReference Include="Delphi.Mocks.VirtualInterface.pas"/>
<DCCReference Include="Delphi.Mocks.VirtualMethodInterceptor.pas"/>
<DCCReference Include="Delphi.Mocks.WeakReference.pas"/>
<DCCReference Include="Delphi.Mocks.When.pas"/>
<DCCReference Include="Sample1Main.pas"/>
<DCCReference Include="Examples\Delphi.Mocks.Example.ProjectSaveCheckVisitor.pas"/>
<DCCReference Include="Examples\Delphi.Mocks.Examples.Factory.pas"/>
<DCCReference Include="Examples\Delphi.Mocks.Examples.Implement.pas"/>
<DCCReference Include="Examples\Delphi.Mocks.Examples.Interfaces.pas"/>
<DCCReference Include="Delphi.Mocks.Example.ProjectSaveCheckVisitor.pas"/>
<DCCReference Include="Delphi.Mocks.Examples.Factory.pas"/>
<DCCReference Include="Delphi.Mocks.Examples.Implement.pas"/>
<DCCReference Include="Delphi.Mocks.Examples.Interfaces.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
Expand Down Expand Up @@ -201,20 +183,28 @@
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<Excluded_Packages/>
<Excluded_Packages>
<Excluded_Packages Name="I:\FBAT_HG_LIBS8\madCollection\madBasic\BDS9\win32\madBasic_.bpl">madBasic 1.2.7 - www.madshi.net</Excluded_Packages>
<Excluded_Packages Name="I:\FBAT_HG_LIBS8\madCollection\madBasic\BDS9\win32\madHelp_.bpl">madHelp 1.1.1 - www.madshi.net</Excluded_Packages>
<Excluded_Packages Name="I:\FBAT_HG_LIBS8\madCollection\madDisAsm\BDS9\win32\madDisAsm_.bpl">madDisAsm 2.2.6 - www.madshi.net</Excluded_Packages>
<Excluded_Packages Name="I:\FBAT_HG_LIBS8\madCollection\madExcept\BDS9\win32\madExceptIde_.bpl">madExceptIde 1.1.0 - www.madshi.net</Excluded_Packages>
<Excluded_Packages Name="I:\FBAT_HG_LIBS8\madCollection\madExcept\BDS9\win32\madExcept_.bpl">madExcept 5.0.0 - www.madshi.net</Excluded_Packages>
<Excluded_Packages Name="I:\FBAT_HG_LIBS8\madCollection\madExcept\BDS9\win32\madExceptVcl_.bpl">madExceptVcl 2.1.0 - www.madshi.net</Excluded_Packages>
<Excluded_Packages Name="I:\FBAT_HG_LIBS8\madCollection\madExcept\BDS9\win32\madExceptWizard_.bpl">madExceptWizard 3.1.8 - www.madshi.net</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality>
<Deployment>
<DeployFile LocalName="Win32\Debug\Sample1.exe" Configuration="Debug" Class="ProjectOutput">
<DeployFile Class="ProjectOutput" Configuration="Debug" LocalName="Win32\Debug\Sample1.exe">
<Platform Name="Win32">
<RemoteName>Sample1.exe</RemoteName>
</Platform>
</DeployFile>
<DeployFile LocalName="Win32\Debug\Sample1.rsm" Configuration="Debug" Class="DebugSymbols">
<DeployFile Class="DebugSymbols" Configuration="Debug" LocalName="Win32\Debug\Sample1.rsm">
<Platform Name="Win32">
<RemoteName>Sample1.rsm</RemoteName>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule">
<DeployFile Class="DependencyModule" LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib">
<Platform Name="OSX32"/>
<Platform Name="iOSSimulator"/>
</DeployFile>
Expand Down
File renamed without changes.
Binary file removed Sample1.RES
Binary file not shown.
46 changes: 0 additions & 46 deletions Sample1.dpr

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ constructor TObjectProxy<T>.Create(const ACreateFunc: TFunc<T>; const AAutoMocke

if not Assigned(ACreateFunc) then
begin
ctor := rType.FindConstructor;
if ctor = nil then
raise EMockException.Create('Could not find constructor Create on type ' + rType.Name);

instance := ctor.Invoke(rType.AsInstance.MetaclassType, []);
end
else
instance := TValue.From<T>(ACreateFunc);
FInstance := instance.AsType<T>();
FVMInterceptor := TVirtualMethodInterceptor.Create(rType.AsInstance.MetaclassType);
ctor := rType.FindConstructor;
if ctor = nil then
raise EMockException.Create('Could not find constructor Create on type ' + rType.Name);

instance := ctor.Invoke(rType.AsInstance.MetaclassType, []);
end
else
instance := TValue.From<T>(ACreateFunc);
FInstance := instance.AsType<T>();
FVMInterceptor := TVirtualMethodInterceptor.Create(rType.AsInstance.MetaclassType);

FVMInterceptor.Proxify(instance.AsObject);
FVMInterceptor.OnBefore := DoBefore;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ function TProxy.GetMethodData(const AMethodName: string; const ATypeName: string

setupParams := TSetupMethodDataParameters.Create(FIsStubOnly, FBehaviorMustBeDefined, FAllowRedefineBehaviorDefinitions);
{$IFNDEF NEXTGEN}
Result := TMethodData.Create(string(FTypeInfo.Name), AMethodName, setupParams, FAutoMocker);
{$ELSE}
Result := TMethodData.Create(FTypeInfo.NameFld.ToString, AMethodName, setupParams, FAutoMocker);
Result := TMethodData.Create(string(FTypeInfo.Name), AMethodName, setupParams, FAutoMocker);
{$ELSE}
Result := TMethodData.Create(FTypeInfo.NameFld.ToString, AMethodName, setupParams, FAutoMocker);
{$ENDIF}
FMethodData.Add(methodName,Result);
end;
Expand Down Expand Up @@ -556,10 +556,10 @@ procedure TProxy.SetParentProxy(const AProxy : IProxy);
end;

function TProxy.SupportsIInterface: Boolean;
begin
Result := (FParentProxy = nil);
end;

begin
Result := (FParentProxy = nil);
end;

function TProxy.ProxyFromType(const ATypeInfo: PTypeInfo): IProxy;
var
interfaceID : TGUID;
Expand Down Expand Up @@ -749,13 +749,13 @@ function TProxy.TProxyVirtualInterface.QueryProxy(const IID: TGUID; out Obj : IP
end;

function TProxy.TProxyVirtualInterface.SupportsIInterface: Boolean;
begin
if FProxy <> nil then
begin
if FProxy <> nil then
Result := FProxy.Data.SupportsIInterface
else
Result := True;
end;

end;

function TProxy.TProxyVirtualInterface._AddRef: Integer;
begin
result := inherited;
Expand Down

0 comments on commit 6a49b49

Please sign in to comment.