I am trying to write unit test that spans the following line
var fileFullName = fileInfo.FullName;
where fileInfo is an instance of FileInfo.
I use fakes to pin a FileInfo object, but I cannot 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;
Microsoft's answer is to create a base class gasket, in this case FileSystemInfo. But if I try this:
ShimFileSystemInfo.AllInstances.FullNameGet = info => OriginalFullName;
This does not work because FileSystemInfo is an abstract class that cannot be created and therefore cannot be customized.
In this particular case, I can get around it because I can combine the DirectoryName and Name properties to make it verifiable, but it seems crazy that I cannot just use the property that I want, because it comes from the database.
Has anyone come to this problem and managed to solve it?
source share