-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Open
Copy link
Labels
Description
[refactor] Replace Path.GetTempPath() with AbstractTester.TestDirectory in tests
Description
Currently, several test classes use Path.GetTempPath() to create temporary directories. To improve consistency and avoid dependency on the system temporary directory, we should refactor these classes to use AbstractTester and its TestDirectory property instead.
Context
A similar refactoring has already been successfully applied to InventoryBuilderPublicTests.cs (see recent commit). This pattern should be applied to all similar test classes.
Classes to refactor
Unit tests (high priority)
-
InventoryBuilderInspectorTests.cs- File:
tests/ByteSync.Client.UnitTests/Services/Inventories/InventoryBuilderInspectorTests.cs - Pattern: Uses
Path.GetTempPath()inSetUp()to create_rootTemp - Action: Inherit from
AbstractTester, replace_rootTempwithTestDirectory.FullName
- File:
-
InventoryComparerPropagateAccessIssuesTests.cs- File:
tests/ByteSync.Client.UnitTests/Services/Comparisons/InventoryComparerPropagateAccessIssuesTests.cs - Pattern: Uses
Path.GetTempPath()inSetUp()to create_tempDirectory - Action: Inherit from
AbstractTester, replace_tempDirectorywithTestDirectory.FullName
- File:
-
LocalApplicationDataManagerTests.cs- File:
tests/ByteSync.Client.UnitTests/Services/Configurations/LocalApplicationDataManagerTests.cs - Pattern: Uses
Path.GetTempPath()in multiple individual tests (lines 84, 134, 183, 246) - Action: Inherit from
AbstractTester, useTestDirectoryin each test
- File:
-
SynchronizationDownloadFinalizerTests.cs- File:
tests/ByteSync.Client.UnitTests/Services/Communications/Transfers/Downloading/SynchronizationDownloadFinalizerTests.cs - Pattern: Uses
Path.GetTempPath()in helper methods (GetTempFilePath(),GetNewTempPath()) - Action: Inherit from
AbstractTester, useTestDirectoryin helper methods
- File:
Special cases (to evaluate)
DataNodeSourcesViewModelTests.cs- UsesPath.GetTempPath()only as a mock value (may not be necessary)E2E_Environment_Setup.cs- End-to-end integration tests (special case)R2UploadDownload_Tests.csandR2DownloadResume_Tests.cs- UsePath.GetTempPath()as mock values
Benefits of refactoring
- ✅ No more dependency on system temporary directory
- ✅ Use of a dedicated directory in user folder (
ByteSync_Automated_Tests) - ✅ Consistency with other tests in the project that already use
AbstractTester - ✅ Simplified and more maintainable code
- ✅ Automatic cleanup management via
AbstractTester
Reference
The refactoring has been successfully applied to InventoryBuilderPublicTests.cs as a reference example.
Checklist
- Refactor
InventoryBuilderInspectorTests.cs - Refactor
InventoryComparerPropagateAccessIssuesTests.cs - Refactor
LocalApplicationDataManagerTests.cs - Refactor
SynchronizationDownloadFinalizerTests.cs - Verify all tests pass after refactoring
- Evaluate special cases and decide if they should be refactored