Skip to content

Commit 9a899a8

Browse files
committed
Improve naming / explicitness
1 parent d4dcc8f commit 9a899a8

12 files changed

Lines changed: 34 additions & 23 deletions

TestHelpers.Tests/MockDirectoryInfoTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace System.IO.Abstractions.TestingHelpers.Tests
55
{
6+
using XFS = MockUnixSupport;
7+
68
[TestFixture]
79
public class MockDirectoryInfoTests
810
{

TestHelpers.Tests/MockDirectoryTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace System.IO.Abstractions.TestingHelpers.Tests
66
{
7+
using XFS = MockUnixSupport;
8+
79
[TestFixture]
810
public class MockDirectoryTests
911
{
@@ -755,7 +757,7 @@ public void MockDirectory_GetParent_ShouldThrowArgumentExceptionIfPathHasIllegal
755757
{
756758
if (XFS.IsUnixPlatform())
757759
{
758-
Assert.Pass();
760+
Assert.Pass("Path.GetInvalidChars() does not return anything on Mono");
759761
return;
760762
}
761763

TestHelpers.Tests/MockFileInfoTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace System.IO.Abstractions.TestingHelpers.Tests
66
{
7+
using XFS = MockUnixSupport;
8+
79
[TestFixture]
810
public class MockFileInfoTests
911
{

TestHelpers.Tests/MockFileSystemTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void Is_Serializable()
9797
public void MockFileSystem_AddDirectory_ShouldCreateDirectory()
9898
{
9999
// Arrange
100-
string baseDirectory = XFS.Path(@"C:\Test");
100+
string baseDirectory = MockUnixSupport.Path(@"C:\Test");
101101
var fileSystem = new MockFileSystem();
102102

103103
// Act

TestHelpers.Tests/MockFileTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace System.IO.Abstractions.TestingHelpers.Tests
88
{
9+
using XFS = MockUnixSupport;
10+
911
[TestFixture]
1012
public class MockFileTests
1113
{

TestHelpers.Tests/MockPathTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace System.IO.Abstractions.TestingHelpers.Tests
55
{
6+
using XFS = MockUnixSupport;
7+
68
public class MockPathTests
79
{
810
static readonly string TestPath = XFS.Path("C:\\test\\test.bmp");

TestHelpers.Tests/CrossPlatformExtensionsTests.cs renamed to TestHelpers.Tests/MockUnixSupportTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
namespace System.IO.Abstractions.TestingHelpers.Tests
55
{
66
[TestFixture]
7-
public class CrossPlatformExtensionsTests
7+
public class MockUnixSupportTests
88
{
99
[Test]
1010
public void Should_Convert_Backslashes_To_Slashes_On_Unix()
1111
{
12-
Assert.AreEqual("/test/", XFS.Path(@"\test\", () => true));
12+
Assert.AreEqual("/test/", MockUnixSupport.Path(@"\test\", () => true));
1313
}
1414

1515
[Test]
1616
public void Should_Remove_Drive_Letter_On_Unix()
1717
{
18-
Assert.AreEqual("/test/", XFS.Path(@"c:\test\", () => true));
18+
Assert.AreEqual("/test/", MockUnixSupport.Path(@"c:\test\", () => true));
1919
}
2020
}
2121
}

TestHelpers.Tests/TestHelpers.Tests.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@
5757
</PropertyGroup>
5858
<ItemGroup>
5959
<Reference Include="System" />
60-
<Reference Include="System.Core">
61-
<RequiredTargetFramework>3.5</RequiredTargetFramework>
62-
</Reference>
60+
<Reference Include="System.Core" />
6361
<Reference Include="nunit.framework">
6462
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
6563
</Reference>
@@ -75,7 +73,7 @@
7573
<Compile Include="MockFileTests.cs" />
7674
<Compile Include="MockPathTests.cs" />
7775
<Compile Include="Properties\AssemblyInfo.cs" />
78-
<Compile Include="CrossPlatformExtensionsTests.cs" />
76+
<Compile Include="MockUnixSupportTests.cs" />
7977
</ItemGroup>
8078
<ItemGroup>
8179
<ProjectReference Include="..\System.IO.Abstractions\System.IO.Abstractions.csproj">

TestingHelpers/MockDirectory.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace System.IO.Abstractions.TestingHelpers
88
{
9+
using XFS = MockUnixSupport;
10+
911
[Serializable]
1012
public class MockDirectory : DirectoryBase
1113
{
@@ -172,19 +174,21 @@ private string[] GetFilesInternal(IEnumerable<string> files, string path, string
172174
path = EnsurePathEndsWithDirectorySeparator(path);
173175
path = mockFileDataAccessor.Path.GetFullPath(path);
174176

175-
string allDirectoriesPattern = XFS.IsUnixPlatform()
177+
bool isUnix = XFS.IsUnixPlatform();
178+
179+
string allDirectoriesPattern = isUnix
176180
? @"([^<>:""/|?*]*/)*"
177181
: @"([^<>:""/\\|?*]*\\)*";
178182

179183
var fileNamePattern = searchPattern == "*"
180-
? XFS.IsUnixPlatform() ? @"[^/]*?/?" : @"[^\\]*?\\?"
184+
? isUnix ? @"[^/]*?/?" : @"[^\\]*?\\?"
181185
: Regex.Escape(searchPattern)
182-
.Replace(@"\*", XFS.IsUnixPlatform() ? @"[^<>:""/|?*]*?" : @"[^<>:""/\\|?*]*?")
183-
.Replace(@"\?", XFS.IsUnixPlatform() ? @"[^<>:""/|?*]?" : @"[^<>:""/\\|?*]?");
186+
.Replace(@"\*", isUnix ? @"[^<>:""/|?*]*?" : @"[^<>:""/\\|?*]*?")
187+
.Replace(@"\?", isUnix ? @"[^<>:""/|?*]?" : @"[^<>:""/\\|?*]?");
184188

185189
var pathPattern = string.Format(
186190
CultureInfo.InvariantCulture,
187-
XFS.IsUnixPlatform() ? @"(?i:^{0}{1}{2}(?:/?)$)" : @"(?i:^{0}{1}{2}(?:\\?)$)",
191+
isUnix ? @"(?i:^{0}{1}{2}(?:/?)$)" : @"(?i:^{0}{1}{2}(?:\\?)$)",
188192
Regex.Escape(path),
189193
searchOption == SearchOption.AllDirectories ? allDirectoriesPattern : string.Empty,
190194
fileNamePattern);

TestingHelpers/MockFileSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace System.IO.Abstractions.TestingHelpers
66
{
7+
using XFS = MockUnixSupport;
8+
79
[Serializable]
810
public class MockFileSystem : IFileSystem, IMockFileDataAccessor
911
{
@@ -21,7 +23,6 @@ public MockFileSystem(IDictionary<string, MockFileData> files, string currentDir
2123
if (String.IsNullOrEmpty(currentDirectory))
2224
currentDirectory = System.IO.Path.GetTempPath();
2325

24-
2526
this.files = new Dictionary<string, MockFileData>(StringComparer.OrdinalIgnoreCase);
2627
pathField = new MockPath(this);
2728
file = new MockFile(this);

0 commit comments

Comments
 (0)