Skip to content

Commit a089d33

Browse files
author
BRUNER Patrick
committed
path.join.. never combine
1 parent 5a438e8 commit a089d33

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/LogExpert.Persister.Tests/PersisterTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public class PersisterTests
1414
public void Setup ()
1515
{
1616
// Create temporary test directory
17-
_testDirectory = Path.Combine(Path.GetTempPath(), "LogExpertTests", Guid.NewGuid().ToString());
17+
_testDirectory = Path.Join(Path.GetTempPath(), "LogExpertTests", Guid.NewGuid().ToString());
1818
_ = Directory.CreateDirectory(_testDirectory);
1919

2020
// Create a subdirectory to simulate application startup path
21-
_applicationStartupPath = Path.Combine(_testDirectory, "ApplicationPath");
21+
_applicationStartupPath = Path.Join(_testDirectory, "ApplicationPath");
2222
_ = Directory.CreateDirectory(_applicationStartupPath);
2323

2424
// Create a test log file
25-
_logFileName = Path.Combine(_testDirectory, "test.log");
25+
_logFileName = Path.Join(_testDirectory, "test.log");
2626
File.WriteAllText(_logFileName, "Test log content");
2727
}
2828

@@ -64,7 +64,7 @@ public void SavePersistenceData_WithApplicationStartupDir_CreatesSessionFilesDir
6464
var savedFileName = Core.Classes.Persister.Persister.SavePersistenceData(_logFileName, persistenceData, preferences, _applicationStartupPath);
6565

6666
// Assert
67-
var expectedDirectory = Path.Combine(_applicationStartupPath, "sessionFiles");
67+
var expectedDirectory = Path.Join(_applicationStartupPath, "sessionFiles");
6868
Assert.That(Directory.Exists(expectedDirectory), Is.True, "sessionFiles directory should be created");
6969
Assert.That(savedFileName, Does.StartWith(expectedDirectory), "Saved file should be in sessionFiles directory");
7070
}
@@ -192,7 +192,7 @@ public void SavePersistenceData_WithDocumentsDir_DoesNotUseApplicationStartupPat
192192
public void SavePersistenceData_WithOwnDir_DoesNotUseApplicationStartupPath ()
193193
{
194194
// Arrange
195-
var customDirectory = Path.Combine(_testDirectory, "CustomSessionDir");
195+
var customDirectory = Path.Join(_testDirectory, "CustomSessionDir");
196196
_ = Directory.CreateDirectory(customDirectory);
197197

198198
var preferences = new Preferences
@@ -257,7 +257,7 @@ public void LoadPersistenceData_WithApplicationStartupDir_FileNotExists_ReturnsN
257257
SaveLocation = SessionSaveLocation.ApplicationStartupDir
258258
};
259259

260-
var nonExistentFile = Path.Combine(_testDirectory, "nonexistent.log");
260+
var nonExistentFile = Path.Join(_testDirectory, "nonexistent.log");
261261

262262
// Act
263263
var loadedData = Core.Classes.Persister.Persister.LoadPersistenceData(nonExistentFile, preferences, _applicationStartupPath);
@@ -458,7 +458,7 @@ public void SavePersistenceData_WithApplicationStartupDir_WhitespacePath_ThrowsA
458458
public void SavePersistenceData_WithApplicationStartupDir_SpecialCharactersInPath_HandlesCorrectly ()
459459
{
460460
// Arrange
461-
var specialPath = Path.Combine(_testDirectory, "Special Path With Spaces & Symbols");
461+
var specialPath = Path.Join(_testDirectory, "Special Path With Spaces & Symbols");
462462
_ = Directory.CreateDirectory(specialPath);
463463

464464
var preferences = new Preferences
@@ -486,7 +486,7 @@ public void SavePersistenceData_WithApplicationStartupDir_SpecialCharactersInPat
486486
public void SavePersistenceData_WithApplicationStartupDir_UnicodeCharactersInPath_HandlesCorrectly ()
487487
{
488488
// Arrange
489-
var unicodePath = Path.Combine(_testDirectory, "Пути_日本語_Ελληνικά");
489+
var unicodePath = Path.Join(_testDirectory, "Пути_日本語_Ελληνικά");
490490
_ = Directory.CreateDirectory(unicodePath);
491491

492492
var preferences = new Preferences
@@ -517,7 +517,7 @@ public void SavePersistenceData_WithApplicationStartupDir_LongPath_HandlesCorrec
517517
var longPath = _applicationStartupPath;
518518
for (int i = 0; i < 10; i++)
519519
{
520-
longPath = Path.Combine(longPath, $"SubDirectory{i}");
520+
longPath = Path.Join(longPath, $"SubDirectory{i}");
521521
}
522522

523523
_ = Directory.CreateDirectory(longPath);
@@ -590,7 +590,7 @@ public void SavePersistenceData_ConcurrentSaves_ToApplicationStartupDir_HandlesC
590590
// Create multiple log files
591591
for (int i = 0; i < 5; i++)
592592
{
593-
var logFile = Path.Combine(_testDirectory, $"concurrent_test_{i}.log");
593+
var logFile = Path.Join(_testDirectory, $"concurrent_test_{i}.log");
594594
File.WriteAllText(logFile, $"Test log {i}");
595595
logFiles.Add(logFile);
596596
}
@@ -629,7 +629,7 @@ public void SavePersistenceData_ConcurrentSaves_ToApplicationStartupDir_HandlesC
629629
public void SavePersistenceData_ApplicationStartupDirNotExists_CreatesDirectory ()
630630
{
631631
// Arrange
632-
var nonExistentAppPath = Path.Combine(_testDirectory, "NonExistentAppPath");
632+
var nonExistentAppPath = Path.Join(_testDirectory, "NonExistentAppPath");
633633
// Don't create the directory - let Persister create it
634634

635635
var preferences = new Preferences
@@ -647,7 +647,7 @@ public void SavePersistenceData_ApplicationStartupDirNotExists_CreatesDirectory
647647
var savedFileName = Core.Classes.Persister.Persister.SavePersistenceData(_logFileName, persistenceData, preferences, nonExistentAppPath);
648648

649649
// Assert
650-
var expectedDirectory = Path.Combine(nonExistentAppPath, "sessionFiles");
650+
var expectedDirectory = Path.Join(nonExistentAppPath, "sessionFiles");
651651
Assert.That(Directory.Exists(expectedDirectory), Is.True, "Should create sessionFiles directory");
652652
Assert.That(File.Exists(savedFileName), Is.True, "Should create persistence file");
653653
}

0 commit comments

Comments
 (0)