Hi dhelper
sorry for my late response but without email subscription to my post i cannot follow them easily. Do not know why u can not fix such an easy issue
anyway here is the code
[TestFixture]
public class TestFixture1
{
[Test]
public void Test()
{
var myClass = Isolate.Fake.Instance<MyClass>();
Isolate.WhenCalled(() => myClass.DoSomething()).CallOriginal();
int something = myClass.DoSomething();
Assert.AreEqual(1, something);
}
}
internal class CombpexBaseClass
{
public int CompexBaseMethod()
{
return 3;
}
}
internal class MyClass:CombpexBaseClass
{
public int DoSomething()
{
int method = CompexBaseMethod();
return method+1;
}
}
this code passes the test and then i refactor MyClass to something like
internal class MyClass:CombpexBaseClass
{
public int DoSomething()
{
return doSOmething();
}
private int doSOmething()
{
int method = CompexBaseMethod();
return method+1;
}
}
of course the test fails and i need a way to unface all private methods of MyClass.
i could something like
foreach (var methodInfo in typeof(MyClass).GetMethods(BindingFlags.Instance|BindingFlags.NonPublic))
{
Isolate.NonPublic.WhenCalled(myClass,methodInfo.Name).CallOriginal();
}
but i get an exception
Cannot mock methods defined in types from mscorlib assembly.