c# - How do I MOQ the System.IO.FileInfo class... or any other class without an interface? -


I am writing several unit tests for a logger class created and I want to simulate the file class. I can not find the interface that I use to make the MOQ ... how can you successfully MOQ a class without an interface?

This is also not clear to me how I can use dependency injection if no interface is available:

  Private FileInfo _logFile; Public LogEventProcessorTextFile (FileInfo Logfile) {_logFile = logFile; }  

When I really want to do something like this (note IFileInfo instead of FileInfo):

  Private IFileInfo _logFile; Public LogEventProcessorTextFile (IFileInfo Logfile) {_logFile = logFile; }  

Use a library that has several NAT classes for interfaces and fake rappers Provides classes that themselves do not apply the interface.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -