I have a class with the same method:
class MyClass
{
...............
private static MyClass MeMethod(string myparam)
{
MyClass result = null;
............
string[] dir = Directory.GetFiles(myparam);
.........
return result;
}
................
}
And I need to test it with isolating Directory.GetFiles call. I've tried something like this:
var myClassFake = Isolate.Fake.Instance<MyClass>(Members.CallOriginal);
Isolate.Fake.StaticMethods(typeof(Directory));
var str1 = "some path";
var str2 = "some pattern";
Isolate.WhenCalled(() => Directory.GetFiles(str1, str2)).WillReturn(null);
Utilities.Throws<DirectoryNotFoundException>(() =>
Isolate.Invoke.Method(typeof(MyClass), "MyMethod", myparam),
"", "Invalid msg on validation error");
but it wants work. It throws a DirectoryNotFoundException in line
Isolate.WhenCalled(() => Directory.GetFiles(str1, str2)).WillReturn(null);
You solutions can be?