-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Root.cs
45 lines (39 loc) · 1.53 KB
/
Root.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.IO.Tests
{
public class DirectoryInfo_Root : FileSystemTest
{
[Fact]
public void RootOfRoot()
{
string root = Path.GetPathRoot(TestDirectory);
Assert.Equal(root, new DirectoryInfo(root).Root.FullName);
}
[Fact]
public void TrailingSlashes()
{
string root = Path.GetPathRoot(TestDirectory);
var test = new DirectoryInfo(Path.Combine(TestDirectory, "a") + Path.DirectorySeparatorChar).Root;
Assert.Equal(root, test.FullName);
}
[Fact]
public void DotsInPathAreValid()
{
string root = Path.GetPathRoot(TestDirectory);
var test = new DirectoryInfo(Path.Combine(TestDirectory, "Test", "..", ".", "Test")).Root;
Assert.Equal(root, test.FullName);
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // UNC shares
public void UNCShares()
{
string root = Path.GetPathRoot(Directory.GetCurrentDirectory());
string path = Path.DirectorySeparatorChar + Path.Combine("Machine", "Test");
Assert.Equal(root, new DirectoryInfo(path).Root.FullName);
string root2 = new string(Path.DirectorySeparatorChar, 2) + Path.Combine("Machine", "Test");
Assert.Equal(root2, new DirectoryInfo(root2).Root.FullName);
}
}
}