Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f5e93df
Correcting build status indentation (#377)
muthumalla Oct 23, 2018
0a8ed37
Clone binary contents rather than text contents (#378)
Oct 24, 2018
f05c7fd
Use Nerdbank.GitVersioning (#369)
fgreinacher Oct 25, 2018
0550b00
Update NuGet API key (#382)
tathamoddie Oct 25, 2018
dd4a4b8
Stop calling real IO.Path.GetTempPath() when creating a MockFileSyste…
tehmantra Oct 29, 2018
080e148
Update GitHub auth token (#386)
fgreinacher Oct 30, 2018
4ba0241
Use simple GitBuildVersion for GitHub release
fgreinacher Oct 30, 2018
01a127c
Use AppVeyor build version for GitHub release
fgreinacher Oct 30, 2018
127d89f
Make MockFile.Delete throw exception when file does not exist. (#387)
peter-sereda Nov 5, 2018
2b27e2a
Call base.Close() in MockFileStream.Close() (#398)
biltongza Nov 9, 2018
ec1ca83
Add support for running dotnet commands against solution
fgreinacher Nov 16, 2018
ec1b673
Fix file operations that fail when used with relative paths (#407)
fgreinacher Nov 28, 2018
ccc8000
Made FileSystemWatcher on MockFileSystem mockable (#409)
rkoeninger Dec 1, 2018
a9208ee
Add Dependabot badge to readme (#414)
fgreinacher Dec 1, 2018
7e41fa5
Bump Microsoft.NET.Test.Sdk from 15.0.0 to 15.9.0 (#413)
dependabot[bot] Dec 1, 2018
202a732
Bump NUnit3TestAdapter from 3.9.0 to 3.11.2 (#411)
dependabot[bot] Dec 1, 2018
45ee947
Bump nunit from 3.8.1 to 3.11.0 (#412)
dependabot[bot] Dec 1, 2018
6df48cd
Enable linux configuration in AppVeyor (#415)
fgreinacher Dec 1, 2018
c34ca37
Remove TravisCI badge from README (#416)
fgreinacher Dec 2, 2018
c0da0c0
Return original path from Mock*Info.ToString() (#406)
updateaman Dec 3, 2018
ff52831
Deploy only from release branch (#410)
fgreinacher Dec 4, 2018
47f8baa
Bump Moq from 4.10.0 to 4.10.1 (#417)
dependabot[bot] Dec 4, 2018
ade59ac
Make paths case-sensitive on Unix (#418)
rkoeninger Dec 7, 2018
98f15a1
Bump base version to 3.0 (#408)
fgreinacher Dec 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/System.IO.Abstractions.TestingHelpers.Tests/bin/Debug/netcoreapp2.0/System.IO.Abstractions.TestingHelpers.Tests.dll",
"args": [],
"cwd": "${workspaceFolder}/System.IO.Abstractions.TestingHelpers.Tests",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/System.IO.Abstractions.TestingHelpers.Tests/System.IO.Abstractions.TestingHelpers.Tests.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributor guide

## Versioning

This library uses [Nerdbank.GitVersioning](https://github.com/AArnott/Nerdbank.GitVersioning) for generating stable and reproducible version numbers.

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.

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.

## Branches / tags

* `master` contains the latest sources - this is where we develop.
* `release` contains the sources for the latest version on `nuget.org` - this is where we deploy from.
* All versions on `nuget.org` have a matching GitHub release/tag

### Release workflow

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.
1. Inspect CI run (test results, version number)
1. Merge PR and wait for deployment
1. Inspect newly created package versions on NuGet.org and newly created GitHub release
5 changes: 5 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<Target Name="VSTestIfTestProject">
<CallTarget Targets="VSTest" Condition="'$(IsTestable)' == 'true'" />
</Target>
</Project>
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[![NuGet](https://img.shields.io/nuget/v/System.IO.Abstractions.svg)](https://www.nuget.org/packages/System.IO.Abstractions)

[![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

[![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
[![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)

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public static IEnumerable<object[]> MockDirectoryInfo_Exists_Cases
{
get
{
yield return new object[]{ XFS.Path(@"c:\temp\folder"), true };
yield return new object[]{ XFS.Path(@"c:\temp\folder\notExistant"), false };
yield return new object[] { XFS.Path(@"c:\temp\folder"), true };
yield return new object[] { XFS.Path(@"c:\temp\folder\notExistant"), false };
}
}

Expand Down Expand Up @@ -152,8 +152,8 @@ public void MockDirectoryInfo_GetParent_ShouldReturnDirectoriesAndNamesWithSearc
[Test]
public void MockDirectoryInfo_EnumerateFiles_ShouldReturnAllFiles()
{
// Arrange
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
// Arrange
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
//Files "above" in folder we're querying
{ XFS.Path(@"c:\temp\a.txt"), "" },
Expand All @@ -166,11 +166,11 @@ public void MockDirectoryInfo_EnumerateFiles_ShouldReturnAllFiles()
{ XFS.Path(@"c:\temp\folder\deeper\d.txt"), "" }
});

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

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

[Test]
Expand Down Expand Up @@ -238,7 +238,7 @@ public void MockDirectoryInfo_Constructor_ShouldThrowArgumentNullException_IfArg
var fileSystem = new MockFileSystem();

// Act
TestDelegate action = () => new MockDirectoryInfo(fileSystem, null);
TestDelegate action = () => new MockDirectoryInfo(fileSystem, null);

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

[Test]
public void MockDirectoryInfo_ToString_ShouldReturnDirectoryName()
[TestCase(@"c:\temp\folder\folder")]
[TestCase(@"..\..\..\Desktop")]
public void MockDirectoryInfo_ToString_ShouldReturnDirectoryName(string directoryName)
{
var directoryPath = XFS.Path(@"c:\temp\folder\folder");

// Arrange
var fileSystem = new MockFileSystem();
var directoryInfo = new MockDirectoryInfo(fileSystem, directoryPath);
var directoryPath = XFS.Path(directoryName);

// Act
var str = directoryInfo.ToString();
var mockDirectoryInfo = new MockDirectoryInfo(new MockFileSystem(), directoryPath);

// Assert
Assert.AreEqual(directoryPath, str);
Assert.AreEqual(directoryPath, mockDirectoryInfo.ToString());
}
}
}
80 changes: 63 additions & 17 deletions System.IO.Abstractions.TestingHelpers.Tests/MockDirectoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@ public void MockDirectory_CreateDirectory_ShouldWorkWithUNCPath()
var fileSystem = new MockFileSystem();

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

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

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

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

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

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

// Assert
Assert.IsTrue(fileSystem.Directory.Exists(XFS.Path(@"\\server\share\", () => false)));
Assert.IsTrue(fileSystem.Directory.Exists(@"\\server\share\"));
}

[Test]
Expand All @@ -599,6 +599,7 @@ public void MockDirectory_Delete_ShouldDeleteDirectory()
}

[Test]
[WindowsOnly(WindowsSpecifics.CaseInsensitivity)]
public void MockDirectory_Delete_ShouldDeleteDirectoryCaseInsensitively()
{
// Arrange
Expand All @@ -614,6 +615,40 @@ public void MockDirectory_Delete_ShouldDeleteDirectoryCaseInsensitively()
Assert.IsFalse(fileSystem.Directory.Exists(XFS.Path(@"c:\bar")));
}

[Test]
[UnixOnly(UnixSpecifics.CaseSensitivity)]
public void MockDirectory_Delete_ShouldThrowDirectoryNotFoundException_WhenSpecifiedWithInDifferentCase()
{
// Arrange
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ "/bar/foo.txt", new MockFileData("Demo text content") }
});

// Act
TestDelegate action = () => fileSystem.Directory.Delete("/BAR", true);

// Assert
Assert.Throws<DirectoryNotFoundException>(action);
}

[Test]
[UnixOnly(UnixSpecifics.CaseSensitivity)]
public void MockDirectory_Delete_ShouldDeleteDirectoryCaseSensitively()
{
// Arrange
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{ "/bar/foo.txt", new MockFileData("Demo text content") }
});

// Act
fileSystem.Directory.Delete("/bar", true);

// Assert
Assert.IsFalse(fileSystem.Directory.Exists("/bar"));
}

[Test]
public void MockDirectory_Delete_ShouldThrowDirectoryNotFoundException()
{
Expand Down Expand Up @@ -849,8 +884,8 @@ public void MockDirectory_GetLogicalDrives_Returns_LogicalDrives()
else
{
Assert.AreEqual(2, drives.Length);
Assert.IsTrue(drives.Contains("c:\\"));
Assert.IsTrue(drives.Contains("d:\\"));
Assert.IsTrue(drives.Contains(@"C:\"));
Assert.IsTrue(drives.Contains(@"D:\"));
}
}
#endif
Expand Down Expand Up @@ -1184,11 +1219,12 @@ public void MockDirectory_GetCurrentDirectory_ShouldReturnValueFromFileSystemCon

Assert.AreEqual(directory, actual);
}



[Test]
public void MockDirectory_GetCurrentDirectory_ShouldReturnDefaultPathWhenNotSet() {
string directory = Path.GetTempPath();
public void MockDirectory_GetCurrentDirectory_ShouldReturnDefaultPathWhenNotSet()
{
string directory = XFS.Path(@"C:\");

var fileSystem = new MockFileSystem();

var actual = fileSystem.Directory.GetCurrentDirectory();
Expand Down Expand Up @@ -1249,14 +1285,9 @@ public void MockDirectory_GetParent_ShouldReturnADirectoryInfoIfPathDoesNotExist
}

[Test]
[WindowsOnly(WindowsSpecifics.StrictPathRules)]
public void MockDirectory_GetParent_ShouldThrowArgumentExceptionIfPathHasIllegalCharacters()
{
if (XFS.IsUnixPlatform())
{
Assert.Pass("Path.GetInvalidChars() does not return anything on Mono");
return;
}

// Arrange
var fileSystem = new MockFileSystem();

Expand All @@ -1281,6 +1312,21 @@ public void MockDirectory_GetParent_ShouldReturnNullIfPathIsRoot()
Assert.IsNull(actualResult);
}

[Test]
[UnixOnly(UnixSpecifics.SlashRoot)]
public void MockDirectory_GetParent_ShouldReturnRootIfDirectoryIsInRoot()
{
// Arrange
var fileSystem = new MockFileSystem();
fileSystem.AddDirectory("/bar");

// Act
var parent = fileSystem.Directory.GetParent("/bar");

// Assert
Assert.AreEqual("/", parent.FullName);
}

public static IEnumerable<string[]> MockDirectory_GetParent_Cases
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void MockDriveInfoFactory_GetDrives_ShouldReturnDrives()
var actualNames = actualResults.Select(d => d.Name);

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

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

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

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

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

[Test]
Expand Down
23 changes: 20 additions & 3 deletions System.IO.Abstractions.TestingHelpers.Tests/MockDriveInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives(string
var driveInfo = new MockDriveInfo(fileSystem, path);

// Assert
Assert.AreEqual(@"C:\", driveInfo.Name);
Assert.AreEqual(@"c:\", driveInfo.Name);
}

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

// Assert
Assert.AreEqual(@"C:\", driveInfo.Name);
Assert.AreEqual(@"c:\", driveInfo.Name);
}

[TestCase(@"\\unc\share")]
Expand All @@ -59,13 +59,30 @@ public void MockDriveInfo_RootDirectory_ShouldReturnTheDirectoryBase()
var fileSystem = new MockFileSystem();
fileSystem.AddDirectory(XFS.Path(@"c:\Test"));
var driveInfo = new MockDriveInfo(fileSystem, "c:");
var expectedDirectory = XFS.Path(@"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());
}
}
}
Loading