Skip to content

Commit 9ded061

Browse files
author
John Reese
authored
Add null check for path (#346)
1 parent a072541 commit 9ded061

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ namespace System.IO.Abstractions.TestingHelpers.Tests
99
[TestFixture]
1010
public class MockFileInfoTests
1111
{
12+
[Test]
13+
public void MockFileInfo_NullPath_ThrowArgumentNullException()
14+
{
15+
var fileSystem = new MockFileSystem();
16+
17+
TestDelegate action = () => new MockFileInfo(fileSystem, null);
18+
19+
Assert.Throws<ArgumentNullException>(action);
20+
21+
}
22+
1223
[Test]
1324
public void MockFileInfo_Exists_ShouldReturnTrueIfFileExistsInMemoryFileSystem()
1425
{

System.IO.Abstractions.TestingHelpers/MockFileInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class MockFileInfo : FileInfoBase
1111
public MockFileInfo(IMockFileDataAccessor mockFileSystem, string path)
1212
{
1313
this.mockFileSystem = mockFileSystem ?? throw new ArgumentNullException(nameof(mockFileSystem));
14-
this.path = path;
14+
this.path = path ?? throw new ArgumentNullException(nameof(path));
1515
}
1616

1717
MockFileData MockFileData

0 commit comments

Comments
 (0)