Hi!
I have an assembly with 2 classes. One of the classes is public with a few methods. These methods make use of the second class which is internal. I am using natural mocking (amazing feature btw :) ) and everything works great until I need to mock the calls to the internal class. The only access to the internal class I have from the test is via the generated code gen accessors (VSCodeGenAccessors.cs). The problem is that the mock for the internal classes ends up mocking the accessor class and not the real internal class.
Here is an example:
public class PublicClass
{
public void publicmethod()
{
int x = InternalClass.internalmethod();
}
}
internal class InternalClass
{
public static int internalmethod()
{
throw new Exception();
}
}
test code:
[TestMethod()]
public void method1Test()
{
PublicClass target = new PublicClass();
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
// The following line obviously doesn't work, but how would you mock an internal class with a static method?
int x = SampleProject_InternalClassAccessor.internalmethod();
recorder.Return(1);
}
target.publicmethod();
}
Any suggestions would be appreciated.
Thanks!