From d439c7f61ccca532018d2ed5818a318a2fc69459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Tue, 3 Dec 2024 22:02:25 +0100 Subject: [PATCH] fix: `Path.GetTempPath` should end with directory separator (#1172) `Path.GetTempPath` should end with directory separator --- .../MockFileSystem.cs | 2 +- .../MockPathTests.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs index 278042cb3..4199c5622 100644 --- a/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs +++ b/src/TestableIO.System.IO.Abstractions.TestingHelpers/MockFileSystem.cs @@ -14,7 +14,7 @@ namespace System.IO.Abstractions.TestingHelpers public class MockFileSystem : FileSystemBase, IMockFileDataAccessor { private const string DEFAULT_CURRENT_DIRECTORY = @"C:\"; - private const string TEMP_DIRECTORY = @"C:\temp"; + private const string TEMP_DIRECTORY = @"C:\temp\"; private readonly IDictionary files; private readonly IDictionary drives; diff --git a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockPathTests.cs b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockPathTests.cs index 3748705b0..d61c49f92 100644 --- a/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockPathTests.cs +++ b/tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockPathTests.cs @@ -382,6 +382,20 @@ public void GetTempPath_Called_ReturnsStringLengthGreaterThanZero() Assert.That(result.Length > 0, Is.True); } + [Test] + public void GetTempPath_ShouldEndWithDirectorySeparator() + { + //Arrange + var mockPath = new MockFileSystem().Path; + var directorySeparator = mockPath.DirectorySeparatorChar.ToString(); + + //Act + var result = mockPath.GetTempPath(); + + //Assert + Assert.That(result, Does.EndWith(directorySeparator)); + } + [Test] [TestCase(null)] [TestCase("")]