Using Visual Studio 2012 to generate stubs with "Add Fakes Assembly", everything works as expected, except it is failing to generate a stub for this interface:
public interface IFileWrapper
{
IEnumerable<string> ReadLines(string path);
bool Exists(string path);
Stream OpenReadStream(string path);
}
When I change the Stream to a FileStream (as Stream is an abstract class and I wanted to check if this is only happening with abstract classes), I am still not able to generate.
When I remove the method signature completely (that is deleting Stream OpenReadStream(string path);
), I am able to generate the stub.
This is my .fake file content:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Diagnostic="true" Verbosity="Noisy">
<Assembly Name="System.IO.Abstractions"/>
<StubGeneration>
<Clear />
<Add AbstractClasses="true"/>
<Add Interfaces="true"/>
</StubGeneration>
<ShimGeneration>
<Clear />
</ShimGeneration>
</Fakes>
This is caused by a limitation in the Fakes' current implementation. You can work around this problem by switching the target framework in your unit test project from 4.0 to 4.5.