Skip to content

Commit d439c7f

Browse files
authored
fix: Path.GetTempPath should end with directory separator (#1172)
`Path.GetTempPath` should end with directory separator
1 parent 3e4b4e2 commit d439c7f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace System.IO.Abstractions.TestingHelpers
1414
public class MockFileSystem : FileSystemBase, IMockFileDataAccessor
1515
{
1616
private const string DEFAULT_CURRENT_DIRECTORY = @"C:\";
17-
private const string TEMP_DIRECTORY = @"C:\temp";
17+
private const string TEMP_DIRECTORY = @"C:\temp\";
1818

1919
private readonly IDictionary<string, FileSystemEntry> files;
2020
private readonly IDictionary<string, MockDriveData> drives;

tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockPathTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,20 @@ public void GetTempPath_Called_ReturnsStringLengthGreaterThanZero()
382382
Assert.That(result.Length > 0, Is.True);
383383
}
384384

385+
[Test]
386+
public void GetTempPath_ShouldEndWithDirectorySeparator()
387+
{
388+
//Arrange
389+
var mockPath = new MockFileSystem().Path;
390+
var directorySeparator = mockPath.DirectorySeparatorChar.ToString();
391+
392+
//Act
393+
var result = mockPath.GetTempPath();
394+
395+
//Assert
396+
Assert.That(result, Does.EndWith(directorySeparator));
397+
}
398+
385399
[Test]
386400
[TestCase(null)]
387401
[TestCase("")]

0 commit comments

Comments
 (0)