|
From: <na...@us...> - 2009-08-06 20:58:34
|
Revision: 818
http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=818&view=rev
Author: nandod
Date: 2009-08-06 20:58:27 +0000 (Thu, 06 Aug 2009)
Log Message:
-----------
* D2009: Fixed problem with I/O of memo fields in InstantPresentation. TInstantBlob and TInstantMemo are now explicitly Ansi. TInstantWideMemo (and TInstantWideString) should be added for handling of unicode text.
+ PrimerExternal_D2009.dproj.
+ A test for TInstantCodeModel.
Modified Paths:
--------------
trunk/Source/Core/InstantPersistence.pas
trunk/Tests/TestIO.dpr
trunk/Tests/TestIO.dproj
trunk/Tests/TestIO_D2009.dpr
trunk/Tests/TestIO_D2009.dproj
Added Paths:
-----------
trunk/Demos/PrimerCross/PrimerExternal_D2009.dpr
trunk/Demos/PrimerCross/PrimerExternal_D2009.dproj
trunk/Demos/PrimerCross/PrimerExternal_D2009.mdr
trunk/Demos/PrimerCross/PrimerExternal_D2009.res
trunk/Tests/TestInstantCode.pas
Added: trunk/Demos/PrimerCross/PrimerExternal_D2009.dpr
===================================================================
--- trunk/Demos/PrimerCross/PrimerExternal_D2009.dpr (rev 0)
+++ trunk/Demos/PrimerCross/PrimerExternal_D2009.dpr 2009-08-06 20:58:27 UTC (rev 818)
@@ -0,0 +1,79 @@
+(*
+ * InstantObjects
+ * Primer Demo - with "external storage" of Part and Parts
+ * Model.pas unit is located in ModelExternal folder
+ *)
+
+(* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is: Seleqt InstantObjects
+ *
+ * The Initial Developer of the Original Code is: Seleqt
+ *
+ * Portions created by the Initial Developer are Copyright (C) 2001-2003
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Carlo Barazzetta, Nando Dessena
+ *
+ * ***** END LICENSE BLOCK ***** *)
+
+program PrimerExternal_D2009;
+
+{$IFDEF LINUX}
+{$I '../../Source/InstantDefines.inc'}
+{$ELSE}
+{$I '..\..\Source\InstantDefines.inc'}
+{$ENDIF}
+
+
+uses
+ Forms,
+ Main in 'Main.pas' {MainForm},
+ Model in 'ModelExternal\Model.pas',
+ ContactView in 'ContactView.pas' {ContactViewForm: TFrame},
+ BasicView in 'BasicView.pas' {BasicViewForm: TFrame},
+ BasicEdit in 'BasicEdit.pas' {BasicEditForm},
+ ContactEdit in 'ContactEdit.pas' {ContactEditForm},
+ PersonEdit in 'PersonEdit.pas' {PersonEditForm},
+ CompanyEdit in 'CompanyEdit.pas' {CompanyEditForm},
+ DemoData in 'DemoData.pas',
+ ContactFilterEdit in 'ContactFilterEdit.pas' {ContactFilterEditForm},
+ MainData in 'MainData.pas' {MainDataModule: TDataModule},
+ ContactBrowse in 'ContactBrowse.pas' {ContactBrowseForm},
+ CompanyBrowse in 'CompanyBrowse.pas' {CompanyBrowseForm},
+ PerformanceView in 'PerformanceView.pas' {PerformanceViewForm: TFrame},
+ Welcome in 'Welcome.pas' {WelcomeForm},
+ PersonBrowse in 'PersonBrowse.pas' {PersonBrowseForm},
+ BasicBrowse in 'BasicBrowse.pas' {BasicBrowseForm},
+ CountryBrowse in 'CountryBrowse.pas' {CountryBrowseForm},
+ DemoDataRequest in 'DemoDataRequest.pas' {DemoDataRequestForm},
+ ContactSort in 'ContactSort.pas' {ContactSortForm},
+ CategoryBrowse in 'CategoryBrowse.pas' {CategoryBrowseForm},
+ HelpView in 'HelpView.pas' {HelpViewForm: TFrame},
+ RandomData in 'RandomData.pas',
+ Stopwatch in 'Stopwatch.pas',
+ Utility in 'Utility.pas',
+ QueryView in 'QueryView.pas' {QueryViewForm: TFrame};
+
+{$R *.res}
+{$R *.mdr} {Model}
+
+begin
+ Application.Initialize;
+ Application.Title := 'InstantObjects Primer Demo with "external storage" of Part and Parts';
+ Application.CreateForm(TMainForm, MainForm);
+ Application.CreateForm(TMainDataModule, MainDataModule);
+ Application.Run;
+end.
Property changes on: trunk/Demos/PrimerCross/PrimerExternal_D2009.dpr
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/Demos/PrimerCross/PrimerExternal_D2009.dproj
===================================================================
--- trunk/Demos/PrimerCross/PrimerExternal_D2009.dproj (rev 0)
+++ trunk/Demos/PrimerCross/PrimerExternal_D2009.dproj 2009-08-06 20:58:27 UTC (rev 818)
@@ -0,0 +1,187 @@
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectGuid>{0d607f9b-9c2b-445d-84fd-7072bc53deff}</ProjectGuid>
+ <MainSource>PrimerExternal_D2009.dpr</MainSource>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
+ <DCC_DependencyCheckOutputName>PrimerExternal.exe</DCC_DependencyCheckOutputName>
+ <ProjectVersion>12.0</ProjectVersion>
+ <Config Condition="'$(Config)'==''">Debug</Config>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
+ <Cfg_1>true</Cfg_1>
+ <CfgParent>Base</CfgParent>
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
+ <Cfg_2>true</Cfg_2>
+ <CfgParent>Base</CfgParent>
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Base)'!=''">
+ <DCC_DependencyCheckOutputName>PrimerExternal_D2009.exe</DCC_DependencyCheckOutputName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Cfg_1)'!=''">
+ <Version>7.0</Version>
+ <DCC_DebugInformation>False</DCC_DebugInformation>
+ <DCC_LocalDebugSymbols>False</DCC_LocalDebugSymbols>
+ <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
+ <DCC_Define>RELEASE;IO_STATEMENT_LOGGING;$(DCC_Define)</DCC_Define>
+ <DCC_UnitSearchPath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
+ <DCC_ResourcePath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_ResourcePath)</DCC_ResourcePath>
+ <DCC_ObjPath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_ObjPath)</DCC_ObjPath>
+ <DCC_IncludePath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_IncludePath)</DCC_IncludePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Cfg_2)'!=''">
+ <DCC_DebugDCUs>true</DCC_DebugDCUs>
+ <Version>7.0</Version>
+ <DCC_Define>DEBUG;IO_STATEMENT_LOGGING;$(DCC_Define)</DCC_Define>
+ <DCC_UnitSearchPath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
+ <DCC_ResourcePath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_ResourcePath)</DCC_ResourcePath>
+ <DCC_ObjPath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_ObjPath)</DCC_ObjPath>
+ <DCC_IncludePath>..\..\Source\Core;..\..\Source\Brokers\ADO;..\..\Source\Brokers\BDE;..\..\Source\Brokers\DBX;..\..\Source\Brokers\IBX;..\..\Source\Brokers\XML;..\..\Source\Catalogs\IBFb;..\..\Source\Catalogs\MSSql;..\..\Source\Catalogs\MySql;$(DCC_IncludePath)</DCC_IncludePath>
+ </PropertyGroup>
+ <ProjectExtensions>
+ <Borland.Personality>Delphi.Personality.12</Borland.Personality>
+ <Borland.ProjectType>VCLApplication</Borland.ProjectType>
+ <BorlandProject>
+ <Delphi.Personality>
+ <Compiler>
+ <Compiler Name="UsePackages">False</Compiler>
+ <Compiler Name="Packages"/>
+ </Compiler>
+ <Parameters>
+ <Parameters Name="UseLauncher">False</Parameters>
+ <Parameters Name="LoadAllSymbols">True</Parameters>
+ <Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
+ </Parameters>
+ <VersionInfo>
+ <VersionInfo Name="IncludeVerInfo">True</VersionInfo>
+ <VersionInfo Name="AutoIncBuild">False</VersionInfo>
+ <VersionInfo Name="MajorVer">2</VersionInfo>
+ <VersionInfo Name="MinorVer">0</VersionInfo>
+ <VersionInfo Name="Release">0</VersionInfo>
+ <VersionInfo Name="Build">0</VersionInfo>
+ <VersionInfo Name="Debug">False</VersionInfo>
+ <VersionInfo Name="PreRelease">False</VersionInfo>
+ <VersionInfo Name="Special">False</VersionInfo>
+ <VersionInfo Name="Private">False</VersionInfo>
+ <VersionInfo Name="DLL">False</VersionInfo>
+ <VersionInfo Name="Locale">1030</VersionInfo>
+ <VersionInfo Name="CodePage">1252</VersionInfo>
+ </VersionInfo>
+ <VersionInfoKeys>
+ <VersionInfoKeys Name="CompanyName">InstantObjects.org</VersionInfoKeys>
+ <VersionInfoKeys Name="FileDescription">Primer Demo</VersionInfoKeys>
+ <VersionInfoKeys Name="FileVersion">2.0.0.0</VersionInfoKeys>
+ <VersionInfoKeys Name="InternalName"/>
+ <VersionInfoKeys Name="LegalCopyright">MPL public license</VersionInfoKeys>
+ <VersionInfoKeys Name="LegalTrademarks"/>
+ <VersionInfoKeys Name="OriginalFilename"/>
+ <VersionInfoKeys Name="ProductName"/>
+ <VersionInfoKeys Name="ProductVersion">2.0</VersionInfoKeys>
+ <VersionInfoKeys Name="Comments"/>
+ </VersionInfoKeys>
+ <Source>
+ <Source Name="MainSource">PrimerExternal_D2009.dpr</Source>
+ </Source>
+ </Delphi.Personality>
+ </BorlandProject>
+ <ProjectFileVersion>12</ProjectFileVersion>
+ </ProjectExtensions>
+ <ItemGroup>
+ <DelphiCompile Include="PrimerExternal_D2009.dpr">
+ <MainSource>MainSource</MainSource>
+ </DelphiCompile>
+ <DCCReference Include="Main.pas">
+ <Form>MainForm</Form>
+ </DCCReference>
+ <DCCReference Include="ModelExternal\Model.pas"/>
+ <DCCReference Include="ContactView.pas">
+ <Form>ContactViewForm</Form>
+ <DesignClass>TFrame</DesignClass>
+ </DCCReference>
+ <DCCReference Include="BasicView.pas">
+ <Form>BasicViewForm</Form>
+ <DesignClass>TFrame</DesignClass>
+ </DCCReference>
+ <DCCReference Include="BasicEdit.pas">
+ <Form>BasicEditForm</Form>
+ </DCCReference>
+ <DCCReference Include="ContactEdit.pas">
+ <Form>ContactEditForm</Form>
+ </DCCReference>
+ <DCCReference Include="PersonEdit.pas">
+ <Form>PersonEditForm</Form>
+ </DCCReference>
+ <DCCReference Include="CompanyEdit.pas">
+ <Form>CompanyEditForm</Form>
+ </DCCReference>
+ <DCCReference Include="DemoData.pas"/>
+ <DCCReference Include="ContactFilterEdit.pas">
+ <Form>ContactFilterEditForm</Form>
+ </DCCReference>
+ <DCCReference Include="MainData.pas">
+ <Form>MainDataModule</Form>
+ <DesignClass>TDataModule</DesignClass>
+ </DCCReference>
+ <DCCReference Include="ContactBrowse.pas">
+ <Form>ContactBrowseForm</Form>
+ </DCCReference>
+ <DCCReference Include="CompanyBrowse.pas">
+ <Form>CompanyBrowseForm</Form>
+ </DCCReference>
+ <DCCReference Include="PerformanceView.pas">
+ <Form>PerformanceViewForm</Form>
+ <DesignClass>TFrame</DesignClass>
+ </DCCReference>
+ <DCCReference Include="Welcome.pas">
+ <Form>WelcomeForm</Form>
+ </DCCReference>
+ <DCCReference Include="PersonBrowse.pas">
+ <Form>PersonBrowseForm</Form>
+ </DCCReference>
+ <DCCReference Include="BasicBrowse.pas">
+ <Form>BasicBrowseForm</Form>
+ </DCCReference>
+ <DCCReference Include="CountryBrowse.pas">
+ <Form>CountryBrowseForm</Form>
+ </DCCReference>
+ <DCCReference Include="DemoDataRequest.pas">
+ <Form>DemoDataRequestForm</Form>
+ </DCCReference>
+ <DCCReference Include="ContactSort.pas">
+ <Form>ContactSortForm</Form>
+ </DCCReference>
+ <DCCReference Include="CategoryBrowse.pas">
+ <Form>CategoryBrowseForm</Form>
+ </DCCReference>
+ <DCCReference Include="HelpView.pas">
+ <Form>HelpViewForm</Form>
+ <DesignClass>TFrame</DesignClass>
+ </DCCReference>
+ <DCCReference Include="RandomData.pas"/>
+ <DCCReference Include="Stopwatch.pas"/>
+ <DCCReference Include="Utility.pas"/>
+ <DCCReference Include="QueryView.pas">
+ <Form>QueryViewForm</Form>
+ <DesignClass>TFrame</DesignClass>
+ </DCCReference>
+ <BuildConfiguration Include="Base">
+ <Key>Base</Key>
+ </BuildConfiguration>
+ <BuildConfiguration Include="Debug">
+ <Key>Cfg_2</Key>
+ <CfgParent>Base</CfgParent>
+ </BuildConfiguration>
+ <BuildConfiguration Include="Release">
+ <Key>Cfg_1</Key>
+ <CfgParent>Base</CfgParent>
+ </BuildConfiguration>
+ </ItemGroup>
+ <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
+ </Project>
Property changes on: trunk/Demos/PrimerCross/PrimerExternal_D2009.dproj
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/Demos/PrimerCross/PrimerExternal_D2009.mdr
===================================================================
(Binary files differ)
Property changes on: trunk/Demos/PrimerCross/PrimerExternal_D2009.mdr
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/Demos/PrimerCross/PrimerExternal_D2009.res
===================================================================
(Binary files differ)
Property changes on: trunk/Demos/PrimerCross/PrimerExternal_D2009.res
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/Source/Core/InstantPersistence.pas
===================================================================
--- trunk/Source/Core/InstantPersistence.pas 2009-08-06 17:14:40 UTC (rev 817)
+++ trunk/Source/Core/InstantPersistence.pas 2009-08-06 20:58:27 UTC (rev 818)
@@ -444,10 +444,10 @@
FStream: TMemoryStream;
function GetSize: Integer;
function GetStream: TMemoryStream;
- function GetValue: string;
- procedure SetValue(const AValue: string);
property Stream: TMemoryStream read GetStream;
protected
+ function GetValue: AnsiString; virtual;
+ procedure SetValue(const AValue: AnsiString); virtual;
class function AttributeType: TInstantAttributeType; override;
function GetAsString: string; override;
function GetAsVariant: Variant; override;
@@ -472,7 +472,7 @@
function WriteBuffer(const Buffer; Position, Count: Integer): Integer;
property Size: Integer read GetSize;
published
- property Value: string read GetValue write SetValue;
+ property Value: AnsiString read GetValue write SetValue;
end;
TInstantMemo = class(TInstantBlob)
@@ -3485,13 +3485,14 @@
Result := FStream;
end;
-function TInstantBlob.GetValue: string;
+function TInstantBlob.GetValue: AnsiString;
begin
if Size > 0 then
begin
- SetLength(Result, Size div SizeOf(Char));
+ SetLength(Result, Size div SizeOf(AnsiChar));
Read(Result[1], 0, Size);
- end else
+ end
+ else
Result := '';
end;
@@ -3567,17 +3568,18 @@
end;
end;
-procedure TInstantBlob.SetValue(const AValue: string);
+procedure TInstantBlob.SetValue(const AValue: AnsiString);
var
L: Integer;
begin
- L := Length(AValue) * SizeOf(Char);
+ L := Length(AValue) * SizeOf(AnsiChar);
if L > 0 then
begin
Stream.Clear;
WriteBuffer(AValue[1], 0, L);
Stream.Size := L;
- end else
+ end
+ else
Clear;
end;
Modified: trunk/Tests/TestIO.dpr
===================================================================
--- trunk/Tests/TestIO.dpr 2009-08-06 17:14:40 UTC (rev 817)
+++ trunk/Tests/TestIO.dpr 2009-08-06 20:58:27 UTC (rev 818)
@@ -58,7 +58,8 @@
TestInstantCircularReferences in 'TestInstantCircularReferences.pas',
TestInstantObjectReference in 'TestInstantObjectReference.pas',
MinimalModel in 'MinimalModel.pas',
- TestXMLBroker in 'TestXMLBroker.pas';
+ TestXMLBroker in 'TestXMLBroker.pas',
+ TestInstantCode in 'TestInstantCode.pas';
{$R *.res}
{$R *.mdr} {TestModel}
Modified: trunk/Tests/TestIO.dproj
===================================================================
--- trunk/Tests/TestIO.dproj 2009-08-06 17:14:40 UTC (rev 817)
+++ trunk/Tests/TestIO.dproj 2009-08-06 20:58:27 UTC (rev 818)
@@ -55,6 +55,7 @@
<DCCReference Include="TestInstantCircularReferences.pas" />
<DCCReference Include="TestInstantClasses.pas" />
<DCCReference Include="TestInstantClassMetadata.pas" />
+ <DCCReference Include="TestInstantCode.pas" />
<DCCReference Include="TestInstantComplex.pas" />
<DCCReference Include="TestInstantCurrency.pas" />
<DCCReference Include="TestInstantDate.pas" />
Modified: trunk/Tests/TestIO_D2009.dpr
===================================================================
--- trunk/Tests/TestIO_D2009.dpr 2009-08-06 17:14:40 UTC (rev 817)
+++ trunk/Tests/TestIO_D2009.dpr 2009-08-06 20:58:27 UTC (rev 818)
@@ -52,7 +52,8 @@
TestInstantCircularReferences in 'TestInstantCircularReferences.pas',
TestInstantObjectReference in 'TestInstantObjectReference.pas',
MinimalModel in 'MinimalModel.pas',
- TestXMLBroker in 'TestXMLBroker.pas';
+ TestXMLBroker in 'TestXMLBroker.pas',
+ TestInstantCode in 'TestInstantCode.pas';
{$R *.res}
{$R *.mdr} {TestModel}
Modified: trunk/Tests/TestIO_D2009.dproj
===================================================================
--- trunk/Tests/TestIO_D2009.dproj 2009-08-06 17:14:40 UTC (rev 817)
+++ trunk/Tests/TestIO_D2009.dproj 2009-08-06 20:58:27 UTC (rev 818)
@@ -93,6 +93,7 @@
<DCCReference Include="TestInstantObjectReference.pas"/>
<DCCReference Include="MinimalModel.pas"/>
<DCCReference Include="TestXMLBroker.pas"/>
+ <DCCReference Include="TestInstantCode.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Added: trunk/Tests/TestInstantCode.pas
===================================================================
--- trunk/Tests/TestInstantCode.pas (rev 0)
+++ trunk/Tests/TestInstantCode.pas 2009-08-06 20:58:27 UTC (rev 818)
@@ -0,0 +1,128 @@
+(*
+ * InstantObjects Test Suite
+ * TestMockBroker
+ *)
+
+(* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is: InstantObjects Test Suite/TestMockBroker
+ *
+ * The Initial Developer of the Original Code is: Uberto Barbini
+ *
+ * Portions created by the Initial Developer are Copyright (C) 2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Nando Dessena
+ *
+ * ***** END LICENSE BLOCK ***** *)
+
+unit TestInstantCode;
+
+{$IFDEF LINUX}
+{$I '../InstantDefines.inc'}
+{$ELSE}
+{$I '..\InstantDefines.inc'}
+{$ENDIF}
+
+interface
+
+uses
+ InstantCode, fpcunit, InstantMock, TestModel;
+
+type
+ TTestInstantCodeModel = class(TTestCase)
+ published
+ {
+ This test uses TInstantCodeModel to: read the actual TestModel.pas unit
+ from disk; parse it; rename class TCategory to TCategory2, and checks
+ that the rename succeeded. The modified source code is not saved back to
+ disk.
+ }
+ procedure TestRenameModelClass;
+ end;
+
+implementation
+
+uses
+ SysUtils, Classes, testregistry;
+
+{ TTestInstantCodeModel }
+
+procedure TTestInstantCodeModel.TestRenameModelClass;
+var
+ LCodeModel: TInstantCodeModel;
+ LFile: TStream;
+ LSource: TStringStream;
+ LClass: TInstantCodeClass;
+ LChangeInfo: TInstantCodeClassChangeInfo;
+ LSourceCode: string;
+ LChangedAttrs: TStringList;
+ LNewAttrs: TList;
+begin
+ LCodeModel := TInstantCodeModel.Create;
+ try
+ LFile := TFileStream.Create(ExtractFilePath(ParamStr(0)) + 'TestModel.pas', fmOpenRead);
+ try
+ LSource := TStringStream.Create('');
+ try
+ LSource.CopyFrom(LFile, LFile.Size);
+ LCodeModel.LoadModule(LSource.DataString);
+
+ AssertNotNull(LCodeModel.FindModule('TestModel'));
+ AssertNotNull(LCodeModel.FindClass('TCategory'));
+
+ LClass := LCodeModel.FindClass('TCategory');
+
+ LChangedAttrs := TStringList.Create;
+ try
+ LNewAttrs := TList.Create;
+ try
+ LClass.Name := 'TCategory2';
+ LChangeInfo := TInstantCodeClassChangeInfo.Create(LClass, ctEdit,
+ 'TCategory', LChangedAttrs, LNewAttrs);
+ try
+ LSourceCode := LSource.DataString;
+ LClass.ApplyToSource(LSourceCode, LChangeInfo);
+
+ LCodeModel.Clear;
+ LCodeModel.LoadModule(LSourceCode);
+
+ AssertNotNull('Renamed class not found', LCodeModel.FindClass('TCategory2'));
+ AssertNull('Old class is still there', LCodeModel.FindClass('TCategory'));
+ finally
+ LChangeInfo.Free;
+ end;
+ finally
+ LNewAttrs.Free;
+ end;
+ finally
+ LChangedAttrs.Free;
+ end;
+ finally
+ LSource.Free;
+ end;
+ finally
+ LFile.Free;
+ end;
+ finally
+ LCodeModel.Free;
+ end;
+end;
+
+initialization
+{$IFNDEF CURR_TESTS}
+ RegisterTests([TTestInstantCodeModel]);
+{$ENDIF}
+end.
Property changes on: trunk/Tests/TestInstantCode.pas
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
|