Ok, this one took me a WHILE to figure out. Not sure exactly how to explain it...
but this scenario will fail to be mocked:
My test calls the first method, which then calls the 2nd method.
The Directory.Exists will NOT be mocked if the method is marked as private. If I change it to public, the mock will take place.
I've included a sample project for your review.
http://dl.dropbox.com/u/1006254/JustMockTestProject4.zip
forgot to mention: I'm using MSTest
but this scenario will fail to be mocked:
public
static
bool
DirectoryExists(
string
directory)
{
return
DirectoryExists(
new
DirectoryInfo(directory));
}
private
static
bool
DirectoryExists(DirectoryInfo directory)
{
bool
value = Directory.Exists(directory.FullName);
return
value;
}
My test calls the first method, which then calls the 2nd method.
The Directory.Exists will NOT be mocked if the method is marked as private. If I change it to public, the mock will take place.
I've included a sample project for your review.
http://dl.dropbox.com/u/1006254/JustMockTestProject4.zip
forgot to mention: I'm using MSTest