I am trying to write a unit test that covers the following line
var fileFullName = fileInfo.FullName;
where fileInfo is an instance of FileInfo.
I am using fakes to shim the FileInfo object, but I am unable to provide a value for the FullName property, because it is inherited from the base class.
For the Name property, which is not inherited, I can simply do this:
ShimFileInfo.AllInstances.NameGet = info => OriginalFullName;
The answer provided by Microsoft is to create the shim on the base class, in this case FileSystemInfo. But if I try this:
ShimFileSystemInfo.AllInstances.FullNameGet = info => OriginalFullName;
It does not work, because FileSystemInfo is an abstract class which cannot be created and therefore cannot be shimmed.
In this particular case, I can get around it because I can combine the DirectoryName and Name properties to make it testable, but it seems crazy that I can't just use the property I want because it happens to come from the base.
Has anyone come accross this problem and managed to solve it?