Note that there are some explanatory texts on larger screens.

plurals
  1. PONeeded: File system interfaces and implementation in .NET
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1087351/how-do-you-mock-out-the-file-system-in-c-sharp-for-unit-testing">How do you mock out the file system in C# for unit testing?</a> </p> </blockquote> <p>I write unit tests to my code, using Moq as a mocking framework.<br> My code includes calls to the file system, using direct calls to <code>System.IO</code> classes. For instance, <code>File.Exists(...)</code> etc.<br> I'd like to change that code to be more testable, so I should have an interface, say <code>IFile</code>, with a relevant method, say <code>Exists(string path)</code>.<br> I know I can write it from scratch, but I thought that maybe there's a complete, robust framework that has both interfaces and implementations for the file system. This (desired) framework may also be some kind of a "service", and therefore its API doesn't have to be an "interface equivalent" to the <code>System.IO</code> namespace.<br> Note that I'd really like to have interfaces (and <strong>not</strong> static methods) so that my code is ready for dependency injection</p> <h2>What I got so far:</h2> <ul> <li>A somehow similar, yet <a href="https://stackoverflow.com/questions/266776/mock-file-methods-in-net-like-file-copy1-txt-2-txt">not the same question</a> was asked in stackoverflow </li> <li>In <a href="http://www.codeplex.com/" rel="nofollow noreferrer">codeplex.com</a> there's a project named <em>CodePlex Source Control Client</em> (<a href="http://codeplexclient.codeplex.com/" rel="nofollow noreferrer">link</a>) that has such classes in the source code (see <code>/Source/TfsLibrary/Utility/</code> in the source code for specific details) </li> </ul> <p>Any other recommendations?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload