Skip to content

Commit 700af00

Browse files
committed
made pathing to extract file name universal
1 parent 40cb5e9 commit 700af00

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

source/StoneAge.Data.FileSystem.Tests/DocumentTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ public void GivenText_ExpectStringReturned()
4242
actual.Should().Be(expected);
4343
}
4444

45-
[Test]
46-
public void GivenFullFilePath_ExpectFileNameExtracted()
45+
[TestCase(@"c:\tmp\test.txt")]
46+
[TestCase(@"/var/tmp/test.txt")]
47+
public void GivenFullFilePath_ExpectFileNameExtracted(string path)
4748
{
4849
//---------------Arrange-------------------
4950
var input = "a message in a file";
5051

5152
var sut = new DocumentBuilder()
52-
.Using_Name_From_Path(@"c:\tmp\test.txt")
53+
.Using_Name_From_Path(path)
5354
.With_String(input)
5455
.Create_Document();
5556
//---------------Act----------------------

source/StoneAge.Data.FileSystem/DocumentBuilder.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ public IDocumentBuilderData With_Name(string name)
1919

2020
public IDocumentBuilderData Using_Name_From_Path(string path)
2121
{
22-
_name = Path.GetFileName(path);
22+
// Normalize all path separators to the current OS style
23+
var normalized = path
24+
.Replace('\\', Path.DirectorySeparatorChar)
25+
.Replace('/', Path.DirectorySeparatorChar);
26+
_name = Path.GetFileName(normalized);
2327
return this;
2428
}
2529

source/StoneAge.Data.FileSystem/StoneAge.FileStore.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
<PackageId>StoneAge.FileSystem</PackageId>
1212
<Product>StoneAge.FileSystem</Product>
1313
<Authors>T-rav</Authors>
14-
<Version>1.4.3</Version>
14+
<Version>1.4.4</Version>
1515
<PackageReleaseNotes>Adde MoveWithOverwrite to overwrite an existing file when moving</PackageReleaseNotes>
16-
<FileVersion>1.4.3.0</FileVersion>
17-
<AssemblyVersion>1.4.3.0</AssemblyVersion>
16+
<FileVersion>1.4.4.0</FileVersion>
17+
<AssemblyVersion>1.4.4.0</AssemblyVersion>
1818
</PropertyGroup>
1919

2020
</Project>

0 commit comments

Comments
 (0)