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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace System.IO.Abstractions.TestingHelpers.Tests
{
using NUnit.Framework;

/// <summary>
/// Unit tests for the conversion operators of the <see cref="FileInfoBase"/> class.
/// </summary>
public class FileInfoBaseConversionTests
{
/// <summary>
/// Tests that a <c>null</c> <see cref="FileInfo"/> is correctly converted to a <c>null</c> <see cref="FileInfoBase"/> without exception.
/// </summary>
[Test]
public void FileInfoBase_FromFileInfo_ShouldReturnNullIfFileInfoIsNull()
{
// Arrange
FileInfo fileInfo = null;

// Act
FileInfoBase actual = fileInfo;

// Assert
Assert.IsNull(actual);
}
}
}
7 changes: 6 additions & 1 deletion System.IO.Abstractions/FileInfoBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ public abstract class FileInfoBase : FileSystemInfoBase

public static implicit operator FileInfoBase(FileInfo fileInfo)
{
if (fileInfo == null)
{
return null;
}

return new FileInfoWrapper(fileInfo);
}
}
}
}