-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathMockDriveInfoTests.cs
88 lines (72 loc) · 2.65 KB
/
MockDriveInfoTests.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
using NUnit.Framework;
namespace System.IO.Abstractions.TestingHelpers.Tests
{
using XFS = MockUnixSupport;
[TestFixture]
[WindowsOnly(WindowsSpecifics.Drives)]
public class MockDriveInfoTests
{
[TestCase(@"c:")]
[TestCase(@"c:\")]
public void MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives(string driveName)
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddDirectory(XFS.Path(@"c:\Test"));
var path = XFS.Path(driveName);
// Act
var driveInfo = new MockDriveInfo(fileSystem, path);
// Assert
Assert.AreEqual(@"c:\", driveInfo.Name);
}
[Test]
public void MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives_SpecialForWindows()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddDirectory(XFS.Path(@"c:\Test"));
// Act
var driveInfo = new MockDriveInfo(fileSystem, "c");
// Assert
Assert.AreEqual(@"c:\", driveInfo.Name);
}
[TestCase(@"\\unc\share")]
[TestCase(@"\\unctoo")]
public void MockDriveInfo_Constructor_ShouldThrowExceptionIfUncPath(string driveName)
{
// Arrange
var fileSystem = new MockFileSystem();
// Act
TestDelegate action = () => new MockDriveInfo(fileSystem, XFS.Path(driveName));
// Assert
Assert.Throws<ArgumentException>(action);
}
[Test]
public void MockDriveInfo_RootDirectory_ShouldReturnTheDirectoryBase()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddDirectory(XFS.Path(@"c:\Test"));
var driveInfo = new MockDriveInfo(fileSystem, "c:");
var expectedDirectory = XFS.Path(@"c:\");
// Act
var actualDirectory = driveInfo.RootDirectory;
// Assert
Assert.AreEqual(expectedDirectory, actualDirectory.FullName);
}
[TestCase("c:", "c:\\")]
[TestCase("C:", "C:\\")]
[TestCase("d:", "d:\\")]
[TestCase("e:", "e:\\")]
[TestCase("f:", "f:\\")]
public void MockDriveInfo_ToString_ShouldReturnTheDrivePath(string path, string expectedPath)
{
// Arrange
var directoryPath = XFS.Path(path);
// Act
var mockDriveInfo = new MockDriveInfo(new MockFileSystem(), directoryPath);
// Assert
Assert.AreEqual(expectedPath, mockDriveInfo.ToString());
}
}
}