Skip to content

Commit df30d1b

Browse files
committed
Normalize line endings
1 parent 139fdaa commit df30d1b

49 files changed

Lines changed: 5224 additions & 5204 deletions

Some content is hidden

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

.gitattributes

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
1-
# Disable LF normalization for all files
2-
* -text
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

License.txt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
Microsoft Public License (Ms-PL)
2-
3-
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
4-
5-
1. Definitions
6-
7-
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
8-
9-
A "contribution" is the original software, or any additions or changes to the software.
10-
11-
A "contributor" is any person that distributes its contribution under this license.
12-
13-
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
14-
15-
2. Grant of Rights
16-
17-
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
18-
19-
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
20-
21-
3. Conditions and Limitations
22-
23-
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
24-
25-
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
26-
27-
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
28-
29-
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
30-
1+
Microsoft Public License (Ms-PL)
2+
3+
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
4+
5+
1. Definitions
6+
7+
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
8+
9+
A "contribution" is the original software, or any additions or changes to the software.
10+
11+
A "contributor" is any person that distributes its contribution under this license.
12+
13+
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
14+
15+
2. Grant of Rights
16+
17+
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
18+
19+
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
20+
21+
3. Conditions and Limitations
22+
23+
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
24+
25+
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
26+
27+
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
28+
29+
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
30+
3131
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.

Publish-Release.cmd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
@echo off
2-
setlocal
3-
set tempscript=%temp%\%~n0.%random%.ps1
4-
echo $ErrorActionPreference="Stop" >"%tempscript%"
5-
echo ^& "%~dpn0.ps1" %* >>"%tempscript%"
6-
powershell.exe -command "& \"%tempscript%\""
7-
set errlvl=%ERRORLEVEL%
8-
del "%tempscript%"
1+
@echo off
2+
setlocal
3+
set tempscript=%temp%\%~n0.%random%.ps1
4+
echo $ErrorActionPreference="Stop" >"%tempscript%"
5+
echo ^& "%~dpn0.ps1" %* >>"%tempscript%"
6+
powershell.exe -command "& \"%tempscript%\""
7+
set errlvl=%ERRORLEVEL%
8+
del "%tempscript%"
99
exit /b %errlvl%

Publish-Release.ps1

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
param (
2-
[Parameter(Mandatory=$true)]
3-
[ValidatePattern("\d\.\d\.\d\.\d")]
4-
[string]
5-
$ReleaseVersionNumber,
6-
7-
[switch]$Push
8-
)
9-
10-
$ErrorActionPreference = "Stop"
11-
12-
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
13-
14-
$SolutionRoot = Split-Path -Path $PSScriptFilePath -Parent
15-
$NuGetExe = Join-Path $SolutionRoot -ChildPath ".nuget/nuget.exe"
16-
17-
# Build the NuGet package
18-
$ProjectPath = Join-Path -Path $SolutionRoot -ChildPath "System.IO.Abstractions\System.IO.Abstractions.csproj"
19-
& $NuGetExe pack $ProjectPath -Prop Configuration=Release -OutputDirectory $SolutionRoot
20-
if (-not $?)
21-
{
22-
throw "The NuGet process returned an error code."
23-
}
24-
25-
$ProjectPath = Join-Path -Path $SolutionRoot -ChildPath "TestingHelpers\TestingHelpers.csproj"
26-
& $NuGetExe pack $ProjectPath -Prop Configuration=Release -OutputDirectory $SolutionRoot
27-
if (-not $?)
28-
{
29-
throw "The NuGet process returned an error code."
30-
}
31-
32-
# Upload the NuGet package
33-
if ($Push)
34-
{
35-
$NuPkgPath = Join-Path -Path $SolutionRoot -ChildPath "System.IO.Abstractions.$ReleaseVersionNumber.nupkg"
36-
& $NuGetExe push $NuPkgPath
37-
if (-not $?)
38-
{
39-
throw "The NuGet process returned an error code."
40-
}
41-
42-
$NuPkgPath = Join-Path -Path $SolutionRoot -ChildPath "System.IO.Abstractions.TestingHelpers.$ReleaseVersionNumber.nupkg"
43-
& $NuGetExe push $NuPkgPath
44-
if (-not $?)
45-
{
46-
throw "The NuGet process returned an error code."
47-
}
1+
param (
2+
[Parameter(Mandatory=$true)]
3+
[ValidatePattern("\d\.\d\.\d\.\d")]
4+
[string]
5+
$ReleaseVersionNumber,
6+
7+
[switch]$Push
8+
)
9+
10+
$ErrorActionPreference = "Stop"
11+
12+
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
13+
14+
$SolutionRoot = Split-Path -Path $PSScriptFilePath -Parent
15+
$NuGetExe = Join-Path $SolutionRoot -ChildPath ".nuget/nuget.exe"
16+
17+
# Build the NuGet package
18+
$ProjectPath = Join-Path -Path $SolutionRoot -ChildPath "System.IO.Abstractions\System.IO.Abstractions.csproj"
19+
& $NuGetExe pack $ProjectPath -Prop Configuration=Release -OutputDirectory $SolutionRoot
20+
if (-not $?)
21+
{
22+
throw "The NuGet process returned an error code."
23+
}
24+
25+
$ProjectPath = Join-Path -Path $SolutionRoot -ChildPath "TestingHelpers\TestingHelpers.csproj"
26+
& $NuGetExe pack $ProjectPath -Prop Configuration=Release -OutputDirectory $SolutionRoot
27+
if (-not $?)
28+
{
29+
throw "The NuGet process returned an error code."
30+
}
31+
32+
# Upload the NuGet package
33+
if ($Push)
34+
{
35+
$NuPkgPath = Join-Path -Path $SolutionRoot -ChildPath "System.IO.Abstractions.$ReleaseVersionNumber.nupkg"
36+
& $NuGetExe push $NuPkgPath
37+
if (-not $?)
38+
{
39+
throw "The NuGet process returned an error code."
40+
}
41+
42+
$NuPkgPath = Join-Path -Path $SolutionRoot -ChildPath "System.IO.Abstractions.TestingHelpers.$ReleaseVersionNumber.nupkg"
43+
& $NuGetExe push $NuPkgPath
44+
if (-not $?)
45+
{
46+
throw "The NuGet process returned an error code."
47+
}
4848
}

README.markdown

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
Just like System.Web.Abstractions, but for System.IO. Yay for testable IO access!
2-
3-
NuGet only:
4-
5-
Install-Package System.IO.Abstractions
6-
7-
and/or:
8-
9-
Install-Package System.IO.Abstractions.TestingHelpers
10-
11-
At the core of the library is IFileSystem and FileSystem. Instead of calling methods like File.ReadAllText directly, use IFileSystem.File.ReadAllText. We have exactly the same API, except that ours is injectable and testable.
12-
13-
```csharp
14-
public class MyComponent
15-
{
16-
readonly IFileSystem fileSystem;
17-
18-
// <summary>Create MyComponent with the given fileSystem implementation</summary>
19-
public MyComponent(IFileSystem fileSystem)
20-
{
21-
this.fileSystem = fileSystem;
22-
}
23-
/// <summary>Create MyComponent</summary>
24-
public MyComponent() : this(
25-
fileSystem: new FileSystem() //use default implementation which calls System.IO
26-
)
27-
{
28-
}
29-
30-
public void Validate()
31-
{
32-
foreach (var textFile in fileSystem.Directory.GetFiles(@"c:\", "*.txt", SearchOption.TopDirectoryOnly))
33-
{
34-
var text = fileSystem.File.ReadAllText(textFile);
35-
if (text != "Testing is awesome.")
36-
throw new NotSupportedException("We can't go on together. It's not me, it's you.");
37-
}
38-
}
39-
}
40-
```
41-
42-
The library also ships with a series of test helpers to save you from having to mock out every call:
43-
44-
```csharp
45-
[Test]
46-
public void MyComponent_Validate_ShouldThrowNotSupportedExceptionIfTestingIsNotAwesome()
47-
{
48-
// Arrange
49-
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
50-
{
51-
{ @"c:\myfile.txt", new MockFileData("Testing is meh.") },
52-
{ @"c:\demo\jQuery.js", new MockFileData("some js") },
53-
{ @"c:\demo\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) }
54-
});
55-
var component = new MyComponent(fileSystem);
56-
57-
try
58-
{
59-
// Act
60-
component.Validate();
61-
}
62-
catch (NotSupportedException ex)
63-
{
64-
// Assert
65-
Assert.AreEqual("We can't go on together. It's not me, it's you.", ex.Message);
66-
return;
67-
}
68-
69-
Assert.Fail("The expected exception was not thrown.");
70-
}
71-
```
72-
We even support casting from the .NET Framework's untestable types to our testable wrappers:
73-
74-
```csharp
75-
FileInfo SomeBadApiMethodThatReturnsFileInfo()
76-
{
77-
return new FileInfo("a");
78-
}
79-
80-
void MyFancyMethod()
81-
{
82-
var testableFileInfo = (FileInfoBase)SomeBadApiMethodThatReturnsFileInfo();
83-
...
84-
}
1+
Just like System.Web.Abstractions, but for System.IO. Yay for testable IO access!
2+
3+
NuGet only:
4+
5+
Install-Package System.IO.Abstractions
6+
7+
and/or:
8+
9+
Install-Package System.IO.Abstractions.TestingHelpers
10+
11+
At the core of the library is IFileSystem and FileSystem. Instead of calling methods like File.ReadAllText directly, use IFileSystem.File.ReadAllText. We have exactly the same API, except that ours is injectable and testable.
12+
13+
```csharp
14+
public class MyComponent
15+
{
16+
readonly IFileSystem fileSystem;
17+
18+
// <summary>Create MyComponent with the given fileSystem implementation</summary>
19+
public MyComponent(IFileSystem fileSystem)
20+
{
21+
this.fileSystem = fileSystem;
22+
}
23+
/// <summary>Create MyComponent</summary>
24+
public MyComponent() : this(
25+
fileSystem: new FileSystem() //use default implementation which calls System.IO
26+
)
27+
{
28+
}
29+
30+
public void Validate()
31+
{
32+
foreach (var textFile in fileSystem.Directory.GetFiles(@"c:\", "*.txt", SearchOption.TopDirectoryOnly))
33+
{
34+
var text = fileSystem.File.ReadAllText(textFile);
35+
if (text != "Testing is awesome.")
36+
throw new NotSupportedException("We can't go on together. It's not me, it's you.");
37+
}
38+
}
39+
}
40+
```
41+
42+
The library also ships with a series of test helpers to save you from having to mock out every call:
43+
44+
```csharp
45+
[Test]
46+
public void MyComponent_Validate_ShouldThrowNotSupportedExceptionIfTestingIsNotAwesome()
47+
{
48+
// Arrange
49+
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
50+
{
51+
{ @"c:\myfile.txt", new MockFileData("Testing is meh.") },
52+
{ @"c:\demo\jQuery.js", new MockFileData("some js") },
53+
{ @"c:\demo\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) }
54+
});
55+
var component = new MyComponent(fileSystem);
56+
57+
try
58+
{
59+
// Act
60+
component.Validate();
61+
}
62+
catch (NotSupportedException ex)
63+
{
64+
// Assert
65+
Assert.AreEqual("We can't go on together. It's not me, it's you.", ex.Message);
66+
return;
67+
}
68+
69+
Assert.Fail("The expected exception was not thrown.");
70+
}
71+
```
72+
We even support casting from the .NET Framework's untestable types to our testable wrappers:
73+
74+
```csharp
75+
FileInfo SomeBadApiMethodThatReturnsFileInfo()
76+
{
77+
return new FileInfo("a");
78+
}
79+
80+
void MyFancyMethod()
81+
{
82+
var testableFileInfo = (FileInfoBase)SomeBadApiMethodThatReturnsFileInfo();
83+
...
84+
}
8585
```

0 commit comments

Comments
 (0)