Skip to content

Commit f16178a

Browse files
committed
Remove unused test case for volume file names and update path handling in FileExists test
1 parent cfb5053 commit f16178a

2 files changed

Lines changed: 9 additions & 34 deletions

File tree

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem.Test/IO/PetroglyphFileSystemTests.Exist.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,17 @@ public void IsPathFullyQualified_Exists_Internal(string path, bool expected)
168168
var vsb = new ValueStringBuilder();
169169
_pgFileSystem.FileExists(path.AsSpan(), ref vsb, gameDir.AsSpan());
170170

171-
var resultPath = vsb.ToString();
171+
var resultPath = vsb.ToString().Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
172+
var expectedGameDir = gameDir.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
173+
172174
if (expected)
173175
{
174-
Assert.StartsWith(path, resultPath);
175-
Assert.DoesNotContain(gameDir, resultPath);
176+
Assert.StartsWith(path.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar), resultPath);
177+
Assert.DoesNotContain(expectedGameDir, resultPath);
176178
}
177179
else
178180
{
179-
Assert.Contains(gameDir, resultPath);
181+
Assert.Contains(expectedGameDir, resultPath);
180182
}
181183
}
182184
}

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem.Test/IO/PetroglyphFileSystemTests.Names.cs

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
4-
using AnakinRaW.CommonUtilities.FileSystem;
53
using Xunit;
4+
#if NETFRAMEWORK
5+
using AnakinRaW.CommonUtilities.FileSystem;
6+
#endif
67

78
namespace PG.StarWarsGame.Engine.FileSystem.Test.IO;
89

@@ -34,34 +35,6 @@ public void GetFileName_Span(string path, string expected)
3435
Assert.Equal(expected, _pgFileSystem.GetFileName(path));
3536
}
3637

37-
public static IEnumerable<object[]> TestData_GetFileName_Volume()
38-
{
39-
yield return [":", ":"];
40-
yield return [".:", ".:"];
41-
yield return [".:.", ".:."]; // Not a valid drive letter
42-
yield return ["file:", "file:"];
43-
yield return [":file", ":file"];
44-
yield return ["file:exe", "file:exe"];
45-
yield return ["baz\\file:exe", "file:exe"];
46-
yield return ["bar/baz/file:exe", "file:exe"];
47-
}
48-
49-
[Theory, MemberData(nameof(TestData_GetFileName_Volume))]
50-
public void GetFileName_Volume(string path, string expected)
51-
{
52-
// We used to break on ':' on Windows. This is a valid file name character for alternate data streams.
53-
// Additionally, the character can show up on unix volumes mounted to Windows.
54-
#if !NETFRAMEWORK
55-
Assert.Equal(expected, Path.GetFileName(path));
56-
Assert.Equal(expected, _pgFileSystem.GetFileName(path));
57-
#if Windows
58-
Assert.Equal(_pgFileSystem.GetFileName(path), _fileSystem.Path.GetFileName(path.AsSpan()));
59-
#endif
60-
#endif
61-
62-
PathAssert.Equal(expected.AsSpan(), _pgFileSystem.GetFileName(path.AsSpan()));
63-
}
64-
6538
public static TheoryData<string, string> TestData_GetFileNameWithoutExtension => new()
6639
{
6740
{ "", "" },

0 commit comments

Comments
 (0)