How do I make fun of FileInfo information for a file?

I have a script in which I need most of the information from the FileInfo structure - creation time, last recording time, file size, etc. I need to be able to get this information cleanly, but also to be able to truly unit test without getting into the file system.

I use System.IO.Abstractions, so I get 99% of this path for most of my class except this one. I do not know how to use it to get the necessary information from my object MockFileSystem.

public void Initialize(IFileSystem fs, string fullyQualifiedFileName)
{
    string pathOnly = fs.Path.GetDirectoryName(fullyQualifiedFileName);
    string fileName = fs.Path.GetFileName(fullyQualifiedFileName);

    // Here what I don't know how to separate out and mock
    FileInfo fi = new FileInfo(fullyQualifiedFileName);

    long size = fi.LongLength;
    DateTime lastWrite = fi.LastWriteTime;
    ...
    ...
}

Any help on this line would be greatly appreciated.

UPDATE:

This is not an exact duplicate of existing questions, because I am asking how to do this with help System.IO.Abstractions, and not how to do it at all.

, , :

FileInfoBase fi = _fs.FileInfo.FromFileName(fullFilePath);

, , TEST PROD.

+4

Source: https://habr.com/ru/post/1677368/


All Articles