Skip to content

Commit

Permalink
Tests fixes after global settings refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pozitronik committed Dec 11, 2023
1 parent 462ff0b commit 358d761
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 54 deletions.
96 changes: 49 additions & 47 deletions tests/CloudMailRuTest.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,55 @@
{$STRONGLINKTYPES ON}

uses
System.SysUtils,
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX,
{$ELSE}
DUnitX.Loggers.Console,
DUnitX.Loggers.Xml.NUnit,
{$ENDIF }
DUnitX.TestFramework,
TestHelper in 'TestHelper.pas',
TCLoggerTest in 'models\TCLoggerTest.pas',
TCLogger in '..\models\TCLogger.pas',
PLUGIN_TYPES in '..\PLUGIN_TYPES.pas',
SystemHelper in '..\helpers\SystemHelper.pas',
TCProgress in '..\models\TCProgress.pas',
TCProgressTest in 'models\TCProgressTest.pas',
TCRequest in '..\models\TCRequest.pas',
TCRequestTest in 'models\TCRequestTest.pas',
FileHelper in '..\helpers\FileHelper.pas',
PathHelper in '..\helpers\PathHelper.pas',
WindowsHelper in '..\helpers\WindowsHelper.pas',
ConnectionSettings in '..\models\settings\ConnectionSettings.pas',
SETTINGS_CONSTANTS in '..\models\settings\SETTINGS_CONSTANTS.pas',
CMRConstants in '..\CMRConstants.pas',
ProxySettings in '..\models\settings\ProxySettings.pas',
StringHelper in '..\helpers\StringHelper.pas',
TCHelper in '..\helpers\TCHelper.pas',
Description in '..\models\Description.pas',
CMRStrings in '..\CMRStrings.pas',
PluginSettingsManagerTest in 'models\settings\PluginSettingsManagerTest.pas',
AccountsManagerTest in 'models\settings\AccountsManagerTest.pas',
ParsingHelper in '..\helpers\ParsingHelper.pas',
WSList in '..\models\WSList.pas',
AccountSettings in '..\models\settings\AccountSettings.pas',
AccountsManager in '..\models\settings\AccountsManager.pas',
FileCipher in '..\models\cipher\FileCipher.pas',
CMRDirItemList in '..\models\dto\CMRDirItemList.pas',
CMRDirItem in '..\models\dto\CMRDirItem.pas',
JSONHelper in '..\helpers\JSONHelper.pas',
DCPblockciphers in '..\DCPCrypt\DCPblockciphers.pas',
DCPcrypt2 in '..\DCPCrypt\DCPcrypt2.pas',
DCPtypes in '..\DCPCrypt\DCPtypes.pas',
DCPrijndael in '..\DCPCrypt\Ciphers\DCPrijndael.pas',
DCPconst in '..\DCPCrypt\DCPconst.pas',
DCPbase64 in '..\DCPCrypt\DCPbase64.pas',
DCPsha1 in '..\DCPCrypt\Hashes\DCPsha1.pas',
PluginSettingsManager in '..\models\settings\PluginSettingsManager.pas',
PluginSettings in '..\models\settings\PluginSettings.pas';
System.SysUtils,
{$IFDEF TESTINSIGHT}
TestInsight.DUnitX,
{$ELSE}
DUnitX.Loggers.Console,
DUnitX.Loggers.Xml.NUnit,
{$ENDIF }
DUnitX.TestFramework,
TestHelper in 'TestHelper.pas',
TCLoggerTest in 'models\TCLoggerTest.pas',
TCLogger in '..\models\TCLogger.pas',
PLUGIN_TYPES in '..\types\PLUGIN_TYPES.pas',
SystemHelper in '..\helpers\SystemHelper.pas',
TCProgress in '..\models\TCProgress.pas',
TCProgressTest in 'models\TCProgressTest.pas',
TCRequest in '..\models\TCRequest.pas',
TCRequestTest in 'models\TCRequestTest.pas',
FileHelper in '..\helpers\FileHelper.pas',
PathHelper in '..\helpers\PathHelper.pas',
WindowsHelper in '..\helpers\WindowsHelper.pas',
ConnectionSettings in '..\models\settings\ConnectionSettings.pas',
SETTINGS_CONSTANTS in '..\models\settings\SETTINGS_CONSTANTS.pas',
CMRConstants in '..\types\CMRConstants.pas',
ProxySettings in '..\models\settings\ProxySettings.pas',
StringHelper in '..\helpers\StringHelper.pas',
TCHelper in '..\helpers\TCHelper.pas',
Description in '..\models\Description.pas',
LANGUAGE_STRINGS in '..\types\LANGUAGE_STRINGS.pas',
PluginSettingsManagerTest in 'models\settings\PluginSettingsManagerTest.pas',
AccountsManagerTest in 'models\settings\AccountsManagerTest.pas',
ParsingHelper in '..\helpers\ParsingHelper.pas',
WSList in '..\models\WSList.pas',
AccountSettings in '..\models\settings\AccountSettings.pas',
AccountsManager in '..\models\settings\AccountsManager.pas',
FileCipher in '..\models\cipher\FileCipher.pas',
CMRDirItemList in '..\models\dto\CMRDirItemList.pas',
CMRDirItem in '..\models\dto\CMRDirItem.pas',
JSONHelper in '..\helpers\JSONHelper.pas',
DCPblockciphers in '..\DCPCrypt\DCPblockciphers.pas',
DCPcrypt2 in '..\DCPCrypt\DCPcrypt2.pas',
DCPtypes in '..\DCPCrypt\DCPtypes.pas',
DCPrijndael in '..\DCPCrypt\Ciphers\DCPrijndael.pas',
DCPconst in '..\DCPCrypt\DCPconst.pas',
DCPbase64 in '..\DCPCrypt\DCPbase64.pas',
DCPsha1 in '..\DCPCrypt\Hashes\DCPsha1.pas',
PluginSettingsManager in '..\models\settings\PluginSettingsManager.pas',
PluginSettings in '..\models\settings\PluginSettings.pas',
IniFilesHelper in '..\helpers\IniFilesHelper.pas',
StreamingSettings in '..\models\settings\StreamingSettings.pas';

{keep comment here to protect the following conditional from being removed by the IDE when adding a unit}
{$IFNDEF TESTINSIGHT}
Expand Down
8 changes: 5 additions & 3 deletions tests/CloudMailRuTest.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<DCCReference Include="TestHelper.pas"/>
<DCCReference Include="models\TCLoggerTest.pas"/>
<DCCReference Include="..\models\TCLogger.pas"/>
<DCCReference Include="..\PLUGIN_TYPES.pas"/>
<DCCReference Include="..\types\PLUGIN_TYPES.pas"/>
<DCCReference Include="..\helpers\SystemHelper.pas"/>
<DCCReference Include="..\models\TCProgress.pas"/>
<DCCReference Include="models\TCProgressTest.pas"/>
Expand All @@ -121,12 +121,12 @@
<DCCReference Include="..\helpers\WindowsHelper.pas"/>
<DCCReference Include="..\models\settings\ConnectionSettings.pas"/>
<DCCReference Include="..\models\settings\SETTINGS_CONSTANTS.pas"/>
<DCCReference Include="..\CMRConstants.pas"/>
<DCCReference Include="..\types\CMRConstants.pas"/>
<DCCReference Include="..\models\settings\ProxySettings.pas"/>
<DCCReference Include="..\helpers\StringHelper.pas"/>
<DCCReference Include="..\helpers\TCHelper.pas"/>
<DCCReference Include="..\models\Description.pas"/>
<DCCReference Include="..\CMRStrings.pas"/>
<DCCReference Include="..\types\LANGUAGE_STRINGS.pas"/>
<DCCReference Include="models\settings\PluginSettingsManagerTest.pas"/>
<DCCReference Include="models\settings\AccountsManagerTest.pas"/>
<DCCReference Include="..\helpers\ParsingHelper.pas"/>
Expand All @@ -146,6 +146,8 @@
<DCCReference Include="..\DCPCrypt\Hashes\DCPsha1.pas"/>
<DCCReference Include="..\models\settings\PluginSettingsManager.pas"/>
<DCCReference Include="..\models\settings\PluginSettings.pas"/>
<DCCReference Include="..\helpers\IniFilesHelper.pas"/>
<DCCReference Include="..\models\settings\StreamingSettings.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down
2 changes: 1 addition & 1 deletion tests/models/settings/AccountsManagerTest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ procedure TAccountsManagerTest.TestClearPassword;

TestAccountsManager := TAccountsManager.Create(self.AppDir + FP_ACCOUNTS_INI);
Assert.IsNotEmpty(TestAccountsManager.GetAccountSettings('NEW_ACCOUNT').Password);
TestAccountsManager.ClearPassword('NEW_ACCOUNT');
TestAccountsManager.SwitchPasswordStorage('NEW_ACCOUNT');
Assert.IsEmpty(TestAccountsManager.GetAccountSettings('NEW_ACCOUNT').Password);
TestAccountsManager.Free;
end;
Expand Down
5 changes: 2 additions & 3 deletions tests/models/settings/PluginSettingsManagerTest.pas
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ procedure TPluginSettingsManagerTest.TestCreateFindFile;

{It finds no config, but writeable application directory, and uses it}
Assert.AreEqual(self.AppDir, TempSettingsManager.ApplicationPath);
Assert.AreEqual(INI_DIR_PLUGIN, TempSettingsManager.Settings.IniDir);
Assert.isTrue(TempSettingsManager.Settings.IniDir = INI_DIR_PLUGIN);

TempSettingsManager.Free;

Expand All @@ -99,7 +99,7 @@ procedure TPluginSettingsManagerTest.TestCreateFromKnownFile;
TempSettingsManager := TPluginSettingsManager.Create(DataPath(FP_SETTINGS_INI));

{peek some randoms of different data types}
Assert.IsTrue(TempSettingsManager.Settings.DescriptionEnabled); //boolean
Assert.isTrue(TempSettingsManager.Settings.DescriptionEnabled); //boolean
Assert.AreEqual(1000, TempSettingsManager.Settings.AttemptWait); //integer
Assert.AreEqual('descript.ed', TempSettingsManager.Settings.DescriptionFileName); //string
Assert.IsFalse(TempSettingsManager.Settings.ConnectionSettings.ProxySettings.UseTCPasswordManager); //subrecord boolean
Expand All @@ -109,7 +109,6 @@ procedure TPluginSettingsManagerTest.TestCreateFromKnownFile;

end;


initialization

TDUnitX.RegisterTestFixture(TPluginSettingsManagerTest);
Expand Down

0 comments on commit 358d761

Please sign in to comment.