Skip to content

Commit

Permalink
Unit Tests (phase 2) (#33)
Browse files Browse the repository at this point in the history
* Test CanAddField method

* Test CanReplaceField method

* Test CanDeleteField method

* Test AddField method

* Test ReplaceField method

* Test DeleteField method

* Test SwapFields method

* Update uObjectModels.pas

* Add TReplaceTagModelTests

* Add TReplaceFieldNameModelTests

* Add TReplaceFieldValueModelTests

* Add TReplaceRoleModelTests

* Add Testing.XmlStorage

* Add Testing.PrintModel

* Add Testing.HTMLExportModel

* Add Testing.EncryptionPropsModel
  • Loading branch information
maurizuki authored Sep 27, 2024
1 parent 47a107e commit 172ff09
Show file tree
Hide file tree
Showing 9 changed files with 1,633 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/O2/ViewModels/uObjectModels.pas
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ procedure TObjectPropsModel.Build;
function TObjectPropsModel.CanAddField: Boolean;
begin
Result := (FFieldName <> '')
and (FFieldIndex <= FObjectFieldValues.Count)
and (FFieldIndex <= FObjectFieldNames.Count)
and (FObjectFieldNames.IndexOf(FFieldName) = -1);
end;

function TObjectPropsModel.CanDeleteField: Boolean;
begin
Result :=(FFieldIndex >= 0) and (FFieldIndex < FObjectFieldValues.Count);
Result := (FFieldIndex >= 0) and (FFieldIndex < FObjectFieldNames.Count);
end;

function TObjectPropsModel.CanReplaceField: Boolean;
Expand All @@ -227,7 +227,7 @@ function TObjectPropsModel.CanReplaceField: Boolean;
begin
FieldNameIndex := FObjectFieldNames.IndexOf(FFieldName);
Result := (FFieldName <> '')
and (FFieldIndex >= 0) and (FFieldIndex < FObjectFieldValues.Count)
and (FFieldIndex >= 0) and (FFieldIndex < FObjectFieldNames.Count)
and ((FieldNameIndex = -1) or (FieldNameIndex = FFieldIndex));
end;

Expand Down
8 changes: 7 additions & 1 deletion src/Tests/O2TestProject.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ uses
uShellUtils in '..\O2\Utils\uShellUtils.pas',
uUtils in '..\O2\Utils\uUtils.pas',
uHTMLHelper in '..\O2\Utils\uHTMLHelper.pas',
uXmlStorage in '..\O2\Utils\uXmlStorage.pas',
uEncryptionPropsModel in '..\O2\ViewModels\uEncryptionPropsModel.pas',
uEventFilters in '..\O2\ViewModels\uEventFilters.pas',
uFileManager in '..\O2\ViewModels\uFileManager.pas',
Expand All @@ -90,7 +91,12 @@ uses
Testing.FilePropsModel in 'Testing.FilePropsModel.pas',
Testing.ObjectModels in 'Testing.ObjectModels.pas',
Testing.RelationModels in 'Testing.RelationModels.pas',
Testing.RuleModels in 'Testing.RuleModels.pas';
Testing.RuleModels in 'Testing.RuleModels.pas',
Testing.ReplaceOperations in 'Testing.ReplaceOperations.pas',
Testing.XmlStorage in 'Testing.XmlStorage.pas',
Testing.PrintModel in 'Testing.PrintModel.pas',
Testing.HTMLExportModel in 'Testing.HTMLExportModel.pas',
Testing.EncryptionPropsModel in 'Testing.EncryptionPropsModel.pas';

{$IFNDEF TESTINSIGHT}
var
Expand Down
6 changes: 6 additions & 0 deletions src/Tests/O2TestProject.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
<DCCReference Include="..\O2\Utils\uShellUtils.pas"/>
<DCCReference Include="..\O2\Utils\uUtils.pas"/>
<DCCReference Include="..\O2\Utils\uHTMLHelper.pas"/>
<DCCReference Include="..\O2\Utils\uXmlStorage.pas"/>
<DCCReference Include="..\O2\ViewModels\uEncryptionPropsModel.pas"/>
<DCCReference Include="..\O2\ViewModels\uEventFilters.pas"/>
<DCCReference Include="..\O2\ViewModels\uFileManager.pas"/>
Expand All @@ -165,6 +166,11 @@
<DCCReference Include="Testing.ObjectModels.pas"/>
<DCCReference Include="Testing.RelationModels.pas"/>
<DCCReference Include="Testing.RuleModels.pas"/>
<DCCReference Include="Testing.ReplaceOperations.pas"/>
<DCCReference Include="Testing.XmlStorage.pas"/>
<DCCReference Include="Testing.PrintModel.pas"/>
<DCCReference Include="Testing.HTMLExportModel.pas"/>
<DCCReference Include="Testing.EncryptionPropsModel.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down
Loading

0 comments on commit 172ff09

Please sign in to comment.