Skip to content

Commit 5366dcf

Browse files
authored
Merge pull request #419 from System-IO-Abstractions/master
Release v3.0
2 parents cd4d0ea + 98f15a1 commit 5366dcf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+862
-467
lines changed

.travis.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for C# debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/System.IO.Abstractions.TestingHelpers.Tests/bin/Debug/netcoreapp2.0/System.IO.Abstractions.TestingHelpers.Tests.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/System.IO.Abstractions.TestingHelpers.Tests",
16+
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
17+
"console": "internalConsole",
18+
"stopAtEntry": false,
19+
"internalConsoleOptions": "openOnSessionStart"
20+
},
21+
{
22+
"name": ".NET Core Attach",
23+
"type": "coreclr",
24+
"request": "attach",
25+
"processId": "${command:pickProcess}"
26+
}
27+
,]
28+
}

.vscode/tasks.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/System.IO.Abstractions.TestingHelpers.Tests/System.IO.Abstractions.TestingHelpers.Tests.csproj"
11+
],
12+
"problemMatcher": "$msCompile"
13+
}
14+
]
15+
}

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributor guide
2+
3+
## Versioning
4+
5+
This library uses [Nerdbank.GitVersioning](https://github.com/AArnott/Nerdbank.GitVersioning) for generating stable and reproducible version numbers.
6+
7+
The base version is manually maintained in [the version config](version.json). Every build calculates its final version number based on the base version and the number of changes that occured since the last change to the version config.
8+
9+
The base version represents the MAJOR and MINOR parts of [SemVer](https://semver.org). If a PR contains breaking changes or new features the base version has to be changed accordingly. If a PR solely contains minor changes (bug fixes, code improvements) nothing needs to be done as the PATCH number will automatically increment with each commit.
10+
11+
## Branches / tags
12+
13+
* `master` contains the latest sources - this is where we develop.
14+
* `release` contains the sources for the latest version on `nuget.org` - this is where we deploy from.
15+
* All versions on `nuget.org` have a matching GitHub release/tag
16+
17+
### Release workflow
18+
19+
1. Create a [PR from `master` to `release`](https://github.com/System-IO-Abstractions/System.IO.Abstractions/compare/release...master?expand=1) and wait for CI to finish.
20+
1. Inspect CI run (test results, version number)
21+
1. Merge PR and wait for deployment
22+
1. Inspect newly created package versions on NuGet.org and newly created GitHub release

Directory.Build.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<Target Name="VSTestIfTestProject">
3+
<CallTarget Targets="VSTest" Condition="'$(IsTestable)' == 'true'" />
4+
</Target>
5+
</Project>

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[![NuGet](https://img.shields.io/nuget/v/System.IO.Abstractions.svg)](https://www.nuget.org/packages/System.IO.Abstractions)
2-
3-
[![Windows build status](https://ci.appveyor.com/api/projects/status/em172apw1v5k70vq/branch/master?svg=true)](https://ci.appveyor.com/project/tathamoddie/system-io-abstractions/branch/master) on Windows
4-
5-
[![Linux build status](https://travis-ci.org/System-IO-Abstractions/System.IO.Abstractions.svg?branch=master)](https://travis-ci.org/System-IO-Abstractions/System.IO.Abstractions) on Linux
2+
[![Build status](https://ci.appveyor.com/api/projects/status/em172apw1v5k70vq/branch/master?svg=true)](https://ci.appveyor.com/project/tathamoddie/system-io-abstractions/branch/master) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=System-IO-Abstractions/System.IO.Abstractions)](https://dependabot.com)
63

74
---
85

System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryInfoTests.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public static IEnumerable<object[]> MockDirectoryInfo_Exists_Cases
3636
{
3737
get
3838
{
39-
yield return new object[]{ XFS.Path(@"c:\temp\folder"), true };
40-
yield return new object[]{ XFS.Path(@"c:\temp\folder\notExistant"), false };
39+
yield return new object[] { XFS.Path(@"c:\temp\folder"), true };
40+
yield return new object[] { XFS.Path(@"c:\temp\folder\notExistant"), false };
4141
}
4242
}
4343

@@ -152,8 +152,8 @@ public void MockDirectoryInfo_GetParent_ShouldReturnDirectoriesAndNamesWithSearc
152152
[Test]
153153
public void MockDirectoryInfo_EnumerateFiles_ShouldReturnAllFiles()
154154
{
155-
// Arrange
156-
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
155+
// Arrange
156+
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
157157
{
158158
//Files "above" in folder we're querying
159159
{ XFS.Path(@"c:\temp\a.txt"), "" },
@@ -166,11 +166,11 @@ public void MockDirectoryInfo_EnumerateFiles_ShouldReturnAllFiles()
166166
{ XFS.Path(@"c:\temp\folder\deeper\d.txt"), "" }
167167
});
168168

169-
// Act
170-
var directoryInfo = new MockDirectoryInfo(fileSystem, XFS.Path(@"c:\temp\folder"));
169+
// Act
170+
var directoryInfo = new MockDirectoryInfo(fileSystem, XFS.Path(@"c:\temp\folder"));
171171

172-
// Assert
173-
Assert.AreEqual(new[]{"b.txt", "c.txt"}, directoryInfo.EnumerateFiles().ToList().Select(x => x.Name).ToArray());
172+
// Assert
173+
Assert.AreEqual(new[] { "b.txt", "c.txt" }, directoryInfo.EnumerateFiles().ToList().Select(x => x.Name).ToArray());
174174
}
175175

176176
[Test]
@@ -238,7 +238,7 @@ public void MockDirectoryInfo_Constructor_ShouldThrowArgumentNullException_IfArg
238238
var fileSystem = new MockFileSystem();
239239

240240
// Act
241-
TestDelegate action = () => new MockDirectoryInfo(fileSystem, null);
241+
TestDelegate action = () => new MockDirectoryInfo(fileSystem, null);
242242

243243
// Assert
244244
var exception = Assert.Throws<ArgumentNullException>(action);
@@ -272,20 +272,18 @@ public void MockDirectoryInfo_Constructor_ShouldThrowArgumentException_IfArgumen
272272
Assert.That(exception.Message, Does.StartWith("The path is not of a legal form."));
273273
}
274274

275-
[Test]
276-
public void MockDirectoryInfo_ToString_ShouldReturnDirectoryName()
275+
[TestCase(@"c:\temp\folder\folder")]
276+
[TestCase(@"..\..\..\Desktop")]
277+
public void MockDirectoryInfo_ToString_ShouldReturnDirectoryName(string directoryName)
277278
{
278-
var directoryPath = XFS.Path(@"c:\temp\folder\folder");
279-
280279
// Arrange
281-
var fileSystem = new MockFileSystem();
282-
var directoryInfo = new MockDirectoryInfo(fileSystem, directoryPath);
280+
var directoryPath = XFS.Path(directoryName);
283281

284282
// Act
285-
var str = directoryInfo.ToString();
283+
var mockDirectoryInfo = new MockDirectoryInfo(new MockFileSystem(), directoryPath);
286284

287285
// Assert
288-
Assert.AreEqual(directoryPath, str);
286+
Assert.AreEqual(directoryPath, mockDirectoryInfo.ToString());
289287
}
290288
}
291289
}

System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,10 @@ public void MockDirectory_CreateDirectory_ShouldWorkWithUNCPath()
547547
var fileSystem = new MockFileSystem();
548548

549549
// Act
550-
fileSystem.Directory.CreateDirectory(XFS.Path(@"\\server\share\path\to\create", () => false));
550+
fileSystem.Directory.CreateDirectory(@"\\server\share\path\to\create");
551551

552552
// Assert
553-
Assert.IsTrue(fileSystem.Directory.Exists(XFS.Path(@"\\server\share\path\to\create\", () => false)));
553+
Assert.IsTrue(fileSystem.Directory.Exists(@"\\server\share\path\to\create\"));
554554
}
555555

556556
[Test]
@@ -561,7 +561,7 @@ public void MockDirectory_CreateDirectory_ShouldFailIfTryingToCreateUNCPathOnlyS
561561
var fileSystem = new MockFileSystem();
562562

563563
// Act
564-
var ex = Assert.Throws<ArgumentException>(() => fileSystem.Directory.CreateDirectory(XFS.Path(@"\\server", () => false)));
564+
var ex = Assert.Throws<ArgumentException>(() => fileSystem.Directory.CreateDirectory(@"\\server"));
565565

566566
// Assert
567567
StringAssert.StartsWith("The UNC path should be of the form \\\\server\\share.", ex.Message);
@@ -576,10 +576,10 @@ public void MockDirectory_CreateDirectory_ShouldSucceedIfTryingToCreateUNCPathSh
576576
var fileSystem = new MockFileSystem();
577577

578578
// Act
579-
fileSystem.Directory.CreateDirectory(XFS.Path(@"\\server\share", () => false));
579+
fileSystem.Directory.CreateDirectory(@"\\server\share");
580580

581581
// Assert
582-
Assert.IsTrue(fileSystem.Directory.Exists(XFS.Path(@"\\server\share\", () => false)));
582+
Assert.IsTrue(fileSystem.Directory.Exists(@"\\server\share\"));
583583
}
584584

585585
[Test]
@@ -599,6 +599,7 @@ public void MockDirectory_Delete_ShouldDeleteDirectory()
599599
}
600600

601601
[Test]
602+
[WindowsOnly(WindowsSpecifics.CaseInsensitivity)]
602603
public void MockDirectory_Delete_ShouldDeleteDirectoryCaseInsensitively()
603604
{
604605
// Arrange
@@ -614,6 +615,40 @@ public void MockDirectory_Delete_ShouldDeleteDirectoryCaseInsensitively()
614615
Assert.IsFalse(fileSystem.Directory.Exists(XFS.Path(@"c:\bar")));
615616
}
616617

618+
[Test]
619+
[UnixOnly(UnixSpecifics.CaseSensitivity)]
620+
public void MockDirectory_Delete_ShouldThrowDirectoryNotFoundException_WhenSpecifiedWithInDifferentCase()
621+
{
622+
// Arrange
623+
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
624+
{
625+
{ "/bar/foo.txt", new MockFileData("Demo text content") }
626+
});
627+
628+
// Act
629+
TestDelegate action = () => fileSystem.Directory.Delete("/BAR", true);
630+
631+
// Assert
632+
Assert.Throws<DirectoryNotFoundException>(action);
633+
}
634+
635+
[Test]
636+
[UnixOnly(UnixSpecifics.CaseSensitivity)]
637+
public void MockDirectory_Delete_ShouldDeleteDirectoryCaseSensitively()
638+
{
639+
// Arrange
640+
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
641+
{
642+
{ "/bar/foo.txt", new MockFileData("Demo text content") }
643+
});
644+
645+
// Act
646+
fileSystem.Directory.Delete("/bar", true);
647+
648+
// Assert
649+
Assert.IsFalse(fileSystem.Directory.Exists("/bar"));
650+
}
651+
617652
[Test]
618653
public void MockDirectory_Delete_ShouldThrowDirectoryNotFoundException()
619654
{
@@ -849,8 +884,8 @@ public void MockDirectory_GetLogicalDrives_Returns_LogicalDrives()
849884
else
850885
{
851886
Assert.AreEqual(2, drives.Length);
852-
Assert.IsTrue(drives.Contains("c:\\"));
853-
Assert.IsTrue(drives.Contains("d:\\"));
887+
Assert.IsTrue(drives.Contains(@"C:\"));
888+
Assert.IsTrue(drives.Contains(@"D:\"));
854889
}
855890
}
856891
#endif
@@ -1184,11 +1219,12 @@ public void MockDirectory_GetCurrentDirectory_ShouldReturnValueFromFileSystemCon
11841219

11851220
Assert.AreEqual(directory, actual);
11861221
}
1187-
1188-
1222+
11891223
[Test]
1190-
public void MockDirectory_GetCurrentDirectory_ShouldReturnDefaultPathWhenNotSet() {
1191-
string directory = Path.GetTempPath();
1224+
public void MockDirectory_GetCurrentDirectory_ShouldReturnDefaultPathWhenNotSet()
1225+
{
1226+
string directory = XFS.Path(@"C:\");
1227+
11921228
var fileSystem = new MockFileSystem();
11931229

11941230
var actual = fileSystem.Directory.GetCurrentDirectory();
@@ -1249,14 +1285,9 @@ public void MockDirectory_GetParent_ShouldReturnADirectoryInfoIfPathDoesNotExist
12491285
}
12501286

12511287
[Test]
1288+
[WindowsOnly(WindowsSpecifics.StrictPathRules)]
12521289
public void MockDirectory_GetParent_ShouldThrowArgumentExceptionIfPathHasIllegalCharacters()
12531290
{
1254-
if (XFS.IsUnixPlatform())
1255-
{
1256-
Assert.Pass("Path.GetInvalidChars() does not return anything on Mono");
1257-
return;
1258-
}
1259-
12601291
// Arrange
12611292
var fileSystem = new MockFileSystem();
12621293

@@ -1281,6 +1312,21 @@ public void MockDirectory_GetParent_ShouldReturnNullIfPathIsRoot()
12811312
Assert.IsNull(actualResult);
12821313
}
12831314

1315+
[Test]
1316+
[UnixOnly(UnixSpecifics.SlashRoot)]
1317+
public void MockDirectory_GetParent_ShouldReturnRootIfDirectoryIsInRoot()
1318+
{
1319+
// Arrange
1320+
var fileSystem = new MockFileSystem();
1321+
fileSystem.AddDirectory("/bar");
1322+
1323+
// Act
1324+
var parent = fileSystem.Directory.GetParent("/bar");
1325+
1326+
// Assert
1327+
Assert.AreEqual("/", parent.FullName);
1328+
}
1329+
12841330
public static IEnumerable<string[]> MockDirectory_GetParent_Cases
12851331
{
12861332
get

System.IO.Abstractions.TestingHelpers.Tests/MockDriveInfoFactoryTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void MockDriveInfoFactory_GetDrives_ShouldReturnDrives()
2626
var actualNames = actualResults.Select(d => d.Name);
2727

2828
// Assert
29-
Assert.That(actualNames, Is.EquivalentTo(new[] { @"C:\", @"Z:\", @"D:\" }));
29+
Assert.That(actualNames, Is.EquivalentTo(new[] { @"C:\", @"Z:\", @"d:\" }));
3030
}
3131

3232
[Test]
@@ -47,7 +47,7 @@ public void MockDriveInfoFactory_GetDrives_ShouldReturnDrivesWithNoDuplicates()
4747
var actualNames = actualResults.Select(d => d.Name);
4848

4949
// Assert
50-
Assert.That(actualNames, Is.EquivalentTo(new[] { @"C:\", @"Z:\", @"D:\" }));
50+
Assert.That(actualNames, Is.EquivalentTo(new[] { @"C:\", @"Z:\", @"d:\" }));
5151
}
5252

5353
[Test]
@@ -67,7 +67,7 @@ public void MockDriveInfoFactory_GetDrives_ShouldReturnOnlyLocalDrives()
6767
var actualNames = actualResults.Select(d => d.Name);
6868

6969
// Assert
70-
Assert.That(actualNames, Is.EquivalentTo(new[] { @"C:\", @"Z:\", @"D:\" }));
70+
Assert.That(actualNames, Is.EquivalentTo(new[] { @"C:\", @"Z:\", @"d:\" }));
7171
}
7272

7373
[Test]

System.IO.Abstractions.TestingHelpers.Tests/MockDriveInfoTests.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives(string
2121
var driveInfo = new MockDriveInfo(fileSystem, path);
2222

2323
// Assert
24-
Assert.AreEqual(@"C:\", driveInfo.Name);
24+
Assert.AreEqual(@"c:\", driveInfo.Name);
2525
}
2626

2727
[Test]
@@ -35,7 +35,7 @@ public void MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives_Special
3535
var driveInfo = new MockDriveInfo(fileSystem, "c");
3636

3737
// Assert
38-
Assert.AreEqual(@"C:\", driveInfo.Name);
38+
Assert.AreEqual(@"c:\", driveInfo.Name);
3939
}
4040

4141
[TestCase(@"\\unc\share")]
@@ -59,13 +59,30 @@ public void MockDriveInfo_RootDirectory_ShouldReturnTheDirectoryBase()
5959
var fileSystem = new MockFileSystem();
6060
fileSystem.AddDirectory(XFS.Path(@"c:\Test"));
6161
var driveInfo = new MockDriveInfo(fileSystem, "c:");
62-
var expectedDirectory = XFS.Path(@"C:\");
62+
var expectedDirectory = XFS.Path(@"c:\");
6363

6464
// Act
6565
var actualDirectory = driveInfo.RootDirectory;
6666

6767
// Assert
6868
Assert.AreEqual(expectedDirectory, actualDirectory.FullName);
6969
}
70+
71+
[TestCase("c:","c:\\")]
72+
[TestCase("C:","C:\\")]
73+
[TestCase("d:","d:\\")]
74+
[TestCase("e:","e:\\")]
75+
[TestCase("f:","f:\\")]
76+
public void MockDriveInfo_ToString_ShouldReturnTheDrivePath(string path, string expectedPath)
77+
{
78+
// Arrange
79+
var directoryPath = XFS.Path(path);
80+
81+
// Act
82+
var mockDriveInfo = new MockDriveInfo(new MockFileSystem(), directoryPath);
83+
84+
// Assert
85+
Assert.AreEqual(expectedPath, mockDriveInfo.ToString());
86+
}
7087
}
7188
}

0 commit comments

Comments
 (0)