File tree Expand file tree Collapse file tree
System.IO.Abstractions.TestingHelpers.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace System . IO . Abstractions . TestingHelpers . Tests
2+ {
3+ using NUnit . Framework ;
4+
5+ /// <summary>
6+ /// Unit tests for the conversion operators of the <see cref="FileInfoBase"/> class.
7+ /// </summary>
8+ public class FileInfoBaseConversionTests
9+ {
10+ /// <summary>
11+ /// Tests that a <c>null</c> <see cref="FileInfo"/> is correctly converted to a <c>null</c> <see cref="FileInfoBase"/> without exception.
12+ /// </summary>
13+ [ Test ]
14+ public void FileInfoBase_FromFileInfo_ShouldReturnNullIfFileInfoIsNull ( )
15+ {
16+ // Arrange
17+ FileInfo fileInfo = null ;
18+
19+ // Act
20+ FileInfoBase actual = fileInfo ;
21+
22+ // Assert
23+ Assert . IsNull ( actual ) ;
24+ }
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -81,7 +81,12 @@ public abstract class FileInfoBase : FileSystemInfoBase
8181
8282 public static implicit operator FileInfoBase ( FileInfo fileInfo )
8383 {
84+ if ( fileInfo == null )
85+ {
86+ return null ;
87+ }
88+
8489 return new FileInfoWrapper ( fileInfo ) ;
8590 }
8691 }
87- }
92+ }
You can’t perform that action at this time.
0 commit comments