I have the following method.
public string CreateFile(string path, string fileName)
{
string fullPath = path + "ExportedFiles\\";
if (Directory.Exists(fullPath))
{
DirectoryInfo dir = new DirectoryInfo(fullPath);
foreach (FileInfo fi in dir.GetFiles())
{
fi.Delete();
}
}
else
{
Directory.CreateDirectory(fullPath);
}
string filePath = fullPath + fileName;
return filePath;
}
I attempted to used the following in my test case.
[Test, Isolated]
public void TestCreateFileIfPathExists()
{
Isolate.WhenCalled(() => System.IO.Directory.Exists("gsgs")).WillReturn(true);
Isolate.WhenCalled(() => testMyClass.CreateFile(@"D:\testFolder\","TestFile")).CallOriginal();
string result = testMyClass.CreateFile(@"D:\testFolder\", "TestFile");
Assert.AreEqual("D:\\testFolder\\ExportedFiles\\TestFile", result);
}
It's throwing the following typemock exception.
TypeMock.TypeMockException : * No method calls found in recording block. Please check: * Are you trying to fake a field instead of a property? * Are you are trying to fake an unsupported mscorlib type?
Is there any way to solve this?