This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathTestData.cs
96 lines (87 loc) · 2.89 KB
/
TestData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.IO;
using System.Runtime.InteropServices;
using Xunit;
internal static class TestData
{
// see: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file
private static readonly char[] s_invalidFileNameChars = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
new char[]
{
'\"', '<', '>', '|', '\0', (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7,
(char)8, (char)9, (char)10, (char)11, (char)12, (char)13, (char)14, (char)15, (char)16,
(char)17, (char)18, (char)19, (char)20, (char)21, (char)22, (char)23, (char)24, (char)25,
(char)26, (char)27, (char)28, (char)29, (char)30, (char)31, '*', '?'
} :
new char[] { '\0' };
public static TheoryData<string> PathsWithInvalidColons
{
get
{
return new TheoryData<string>
{
// Windows specific. We document that these return NotSupportedException.
@":",
@" :",
@" :",
@"C::",
@"C::FileName",
@"C::FileName.txt",
@"C::FileName.txt:",
@"C::FileName.txt::",
@":f",
@":filename",
@"file:",
@"file:file",
@"http:",
@"http:/",
@"http://",
@"http://www",
@"http://www.microsoft.com",
@"http://www.microsoft.com/index.html",
@"http://server",
@"http://server/",
@"http://server/home",
@"file://",
@"file:///C|/My Documents/ALetter.html"
};
}
}
public static TheoryData<string> PathsWithInvalidCharacters
{
get
{
TheoryData<string> data = new TheoryData<string>
{
"\0",
"middle\0path",
"trailing\0"
};
foreach (char c in s_invalidFileNameChars)
{
data.Add(c.ToString());
}
return data;
}
}
/// <summary>
/// Normal path char and any valid directory separators
/// </summary>
public static TheoryData<char> TrailingCharacters
{
get
{
TheoryData<char> data = new TheoryData<char>
{
// A valid, non separator
'a',
Path.DirectorySeparatorChar
};
if (Path.DirectorySeparatorChar != Path.AltDirectorySeparatorChar)
data.Add(Path.AltDirectorySeparatorChar);
return data;
}
}
}