Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 6 deletions System.IO.Abstractions/DirectoryInfoWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ public class DirectoryInfoWrapper : DirectoryInfoBase

public DirectoryInfoWrapper(DirectoryInfo instance)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}

this.instance = instance;
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
}

public override void Delete()
Expand Down
7 changes: 1 addition & 6 deletions System.IO.Abstractions/DriveInfoWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ public class DriveInfoWrapper : DriveInfoBase
/// <param name="instance">The drive info.</param>
public DriveInfoWrapper(DriveInfo instance)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}

this.instance = instance;
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
}

/// <summary>
Expand Down
7 changes: 1 addition & 6 deletions System.IO.Abstractions/FileInfoWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ public class FileInfoWrapper : FileInfoBase

public FileInfoWrapper(FileInfo instance)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}

this.instance = instance;
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
}

public override void Delete()
Expand Down
32 changes: 6 additions & 26 deletions System.IO.Abstractions/FileSystemWatcherBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static implicit operator FileSystemWatcherBase(FileSystemWatcher watcher)
{
if (watcher == null)
{
throw new ArgumentNullException("watcher");
throw new ArgumentNullException(nameof(watcher));
}

return new FileSystemWatcherWrapper(watcher);
Expand All @@ -52,47 +52,27 @@ public virtual void Dispose(bool disposing)

protected void OnCreated(object sender, FileSystemEventArgs args)
{
var onCreated = Created;
if (onCreated != null)
{
onCreated(sender, args);
}
Created?.Invoke(sender, args);
}

protected void OnChanged(object sender, FileSystemEventArgs args)
{
var onChanged = Changed;
if (onChanged != null)
{
onChanged(sender, args);
}
Changed?.Invoke(sender, args);
}

protected void OnDeleted(object sender, FileSystemEventArgs args)
{
var onDeleted = Deleted;
if (onDeleted != null)
{
onDeleted(sender, args);
}
Deleted?.Invoke(sender, args);
}

protected void OnRenamed(object sender, RenamedEventArgs args)
{
var onRenamed = Renamed;
if (onRenamed != null)
{
onRenamed(sender, args);
}
Renamed?.Invoke(sender, args);
}

protected void OnError(object sender, ErrorEventArgs args)
{
var onError = Error;
if (onError != null)
{
onError(sender, args);
}
Error?.Invoke(sender, args);
}
}
}
7 changes: 1 addition & 6 deletions System.IO.Abstractions/FileSystemWatcherWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ public FileSystemWatcherWrapper(string path, string filter)

public FileSystemWatcherWrapper(FileSystemWatcher watcher)
{
if (watcher == null)
{
throw new ArgumentNullException("watcher");
}

this.watcher = watcher;
this.watcher = watcher ?? throw new ArgumentNullException(nameof(watcher));
this.watcher.Created += OnCreated;
this.watcher.Changed += OnChanged;
this.watcher.Deleted += OnDeleted;
Expand Down
6 changes: 3 additions & 3 deletions TestHelpers.Tests/MockDirectoryGetAccessControlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MockDirectoryGetAccessControlTests
[TestCase(" ")]
public void MockDirectory_GetAccessControl_ShouldThrowArgumentExceptionIfPathContainsOnlyWhitespaces(string path)
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand All @@ -35,7 +35,7 @@ public void MockDirectory_GetAccessControl_ShouldThrowArgumentExceptionIfPathCon
[Test]
public void MockDirectory_GetAccessControl_ShouldThrowDirectoryNotFoundExceptionIfDirectoryDoesNotExistInMockData()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand All @@ -54,7 +54,7 @@ public void MockDirectory_GetAccessControl_ShouldThrowDirectoryNotFoundException
[Test]
public void MockDirectory_GetAccessControl_ShouldReturnAccessControlOfDirectoryData()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand Down
4 changes: 2 additions & 2 deletions TestHelpers.Tests/MockDirectorySetAccessControlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void MockDirectory_SetAccessControl_ShouldThrowArgumentExceptionIfPathCon
[Test]
public void MockDirectory_SetAccessControl_ShouldThrowDirectoryNotFoundExceptionIfDirectoryDoesNotExistInMockData()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand All @@ -56,7 +56,7 @@ public void MockDirectory_SetAccessControl_ShouldThrowDirectoryNotFoundException
[Test]
public void MockDirectory_SetAccessControl_ShouldReturnAccessControlOfDirectoryData()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand Down
14 changes: 7 additions & 7 deletions TestHelpers.Tests/MockDirectoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public void MockDirectory_CreMockDirectory_CreateDirectory_ShouldReturnDirectory
[Test]
public void MockDirectory_CreateDirectory_ShouldWorkWithUNCPath()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand All @@ -560,7 +560,7 @@ public void MockDirectory_CreateDirectory_ShouldWorkWithUNCPath()
[Test]
public void MockDirectory_CreateDirectory_ShouldFailIfTryingToCreateUNCPathOnlyServer()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of UNC paths.");
}
Expand All @@ -579,7 +579,7 @@ public void MockDirectory_CreateDirectory_ShouldFailIfTryingToCreateUNCPathOnlyS
[Test]
public void MockDirectory_CreateDirectory_ShouldSucceedIfTryingToCreateUNCPathShare()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of UNC paths.");
}
Expand Down Expand Up @@ -763,9 +763,9 @@ public static IEnumerable<string> GetSearchPatternForTwoDotsExceptions()
yield return @"a../b";
yield return @"../";

if (!MockUnixSupport.IsUnixPlatform())
if (!XFS.IsUnixPlatform())
{
// These are no problem on Unix platforms
// These are no problems on Unix platforms
yield return @"..\";
yield return @"aaa\vv..\";
yield return @"a..\b";
Expand Down Expand Up @@ -810,7 +810,7 @@ public void MockDirectory_GetFiles_ShouldFindFilesContainingTwoOrMoreDots()
[TestCase("aa\t")]
public void MockDirectory_GetFiles_ShouldThrowAnArgumentException_IfSearchPatternHasIllegalCharacters(string searchPattern)
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have this limitation.");
}
Expand Down Expand Up @@ -1472,7 +1472,7 @@ public void MockDirectory_GetAccessControl_ShouldThrowExceptionOnDirectoryNotFou
[Test]
public void MockDirectory_GetAccessControl_ShouldReturnNewDirectorySecurity()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of UNC paths.");
}
Expand Down
10 changes: 5 additions & 5 deletions TestHelpers.Tests/MockDriveInfoFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MockDriveInfoFactoryTests
[Test]
public void MockDriveInfoFactory_GetDrives_ShouldReturnDrives()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of drives.");
}
Expand All @@ -35,7 +35,7 @@ public void MockDriveInfoFactory_GetDrives_ShouldReturnDrives()
[Test]
public void MockDriveInfoFactory_GetDrives_ShouldReturnDrivesWithNoDuplicates()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of drives.");
}
Expand All @@ -61,7 +61,7 @@ public void MockDriveInfoFactory_GetDrives_ShouldReturnDrivesWithNoDuplicates()
[Test]
public void MockDriveInfoFactory_GetDrives_ShouldReturnOnlyLocalDrives()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of drives.");
}
Expand All @@ -86,7 +86,7 @@ public void MockDriveInfoFactory_GetDrives_ShouldReturnOnlyLocalDrives()
[Test]
public void MockDriveInfoFactory_FromDriveName_WithDriveShouldReturnDrive()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of drives.");
}
Expand All @@ -105,7 +105,7 @@ public void MockDriveInfoFactory_FromDriveName_WithDriveShouldReturnDrive()
[Test]
public void MockDriveInfoFactory_FromDriveName_WithPathShouldReturnDrive()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have the concept of drives.");
}
Expand Down
2 changes: 1 addition & 1 deletion TestHelpers.Tests/MockFileAppendAllLinesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void MockFile_AppendAllLines_ShouldThrowArgumentExceptionIfPathContainsOn
[TestCase("|")]
public void MockFile_AppendAllLines_ShouldThrowArgumentExceptionIfPathContainsInvalidChar(string path)
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have these restrictions.");
}
Expand Down
2 changes: 1 addition & 1 deletion TestHelpers.Tests/MockFileCreateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void Mockfile_Create_ShouldThrowArgumentExceptionIfPathIsZeroLength()
[TestCase("|")]
public void MockFile_Create_ShouldThrowArgumentNullExceptionIfPathIsNull1(string path)
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not have these restrictions.");
}
Expand Down
6 changes: 3 additions & 3 deletions TestHelpers.Tests/MockFileGetAccessControlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MockFileGetAccessControlTests
[TestCase(" ")]
public void MockFile_GetAccessControl_ShouldThrowArgumentExceptionIfPathContainsOnlyWhitespaces(string path)
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand All @@ -35,7 +35,7 @@ public void MockFile_GetAccessControl_ShouldThrowArgumentExceptionIfPathContains
[Test]
public void MockFile_GetAccessControl_ShouldThrowFileNotFoundExceptionIfFileDoesNotExistInMockData()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand All @@ -54,7 +54,7 @@ public void MockFile_GetAccessControl_ShouldThrowFileNotFoundExceptionIfFileDoes
[Test]
public void MockFile_GetAccessControl_ShouldReturnAccessControlOfFileData()
{
if (MockUnixSupport.IsUnixPlatform())
if (XFS.IsUnixPlatform())
{
Assert.Inconclusive("Unix does not support ACLs.");
}
Expand Down
13 changes: 4 additions & 9 deletions TestingHelpers/MockDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ public class MockDirectory : DirectoryBase

public MockDirectory(IMockFileDataAccessor mockFileDataAccessor, FileBase fileBase, string currentDirectory)
{
if (mockFileDataAccessor == null)
{
throw new ArgumentNullException("mockFileDataAccessor");
}

this.currentDirectory = currentDirectory;
this.mockFileDataAccessor = mockFileDataAccessor;
this.mockFileDataAccessor = mockFileDataAccessor ?? throw new ArgumentNullException(nameof(mockFileDataAccessor));
this.fileBase = fileBase;
}

Expand All @@ -45,7 +40,7 @@ private DirectoryInfoBase CreateDirectoryInternal(string path, DirectorySecurity
{
if (path == null)
{
throw new ArgumentNullException("path");
throw new ArgumentNullException(nameof(path));
}

if (path.Length == 0)
Expand Down Expand Up @@ -306,7 +301,7 @@ public override DirectoryInfoBase GetParent(string path)
{
if (path == null)
{
throw new ArgumentNullException("path");
throw new ArgumentNullException(nameof(path));
}

if (path.Length == 0)
Expand Down Expand Up @@ -521,7 +516,7 @@ static void CheckSearchPattern(string searchPattern)
{
if (searchPattern == null)
{
throw new ArgumentNullException("searchPattern");
throw new ArgumentNullException(nameof(searchPattern));
}

const string TWO_DOTS = "..";
Expand Down
7 changes: 1 addition & 6 deletions TestingHelpers/MockDirectoryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ public class MockDirectoryInfo : DirectoryInfoBase
/// <exception cref="ArgumentNullException">Thrown if <paramref name="mockFileDataAccessor"/> or <paramref name="directoryPath"/> is <see langref="null"/>.</exception>
public MockDirectoryInfo(IMockFileDataAccessor mockFileDataAccessor, string directoryPath)
{
if (mockFileDataAccessor == null)
{
throw new ArgumentNullException("mockFileDataAccessor");
}

this.mockFileDataAccessor = mockFileDataAccessor;
this.mockFileDataAccessor = mockFileDataAccessor ?? throw new ArgumentNullException(nameof(mockFileDataAccessor));

directoryPath = mockFileDataAccessor.Path.GetFullPath(directoryPath);

Expand Down
4 changes: 2 additions & 2 deletions TestingHelpers/MockDriveInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public MockDriveInfo(IMockFileDataAccessor mockFileDataAccessor, string name)
{
if (mockFileDataAccessor == null)
{
throw new ArgumentNullException("mockFileDataAccessor");
throw new ArgumentNullException(nameof(mockFileDataAccessor));
}

if (name == null)
{
throw new ArgumentNullException("name");
throw new ArgumentNullException(nameof(name));
}

const string DRIVE_SEPARATOR = @":\";
Expand Down
7 changes: 1 addition & 6 deletions TestingHelpers/MockDriveInfoFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ public class MockDriveInfoFactory : IDriveInfoFactory

public MockDriveInfoFactory(IMockFileDataAccessor mockFileSystem)
{
if (mockFileSystem == null)
{
throw new ArgumentNullException("mockFileSystem");
}

this.mockFileSystem = mockFileSystem;
this.mockFileSystem = mockFileSystem ?? throw new ArgumentNullException(nameof(mockFileSystem));
}

public DriveInfoBase[] GetDrives()
Expand Down
Loading