Hi Kyle,
I'll choose ulu's second option (reflection) to invoke the method.
Here's the ParentPage class:
public class ParentPage: Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Overrides();
}
protected virtual void Overrides()
{
InnerClass.DoSomething();
}
}
internal class InnerClass
{
internal static void DoSomething()
{
Console.WriteLine("DoSomething Was called");
}
}
Now, let's say I want to mock the DoSomething method on the inner class, as well as verify that it has been called. I can do something like this:
[TestMethod]
[VerifyMocks]
public void MockDoSomething_VerifyItWasCalled()
{
Mock pageMock = MockManager.Mock<InnerClass>();
pageMock.ExpectCall("DoSomething");
ParentPage page = new ParentPage();
MethodInfo method = page.GetType().GetMethod("Page_Load", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(page, new object[]{this, null});
}
Note the binding flags I use to invoke the instance's internal method.
I hope this example helps. Let me know if you need additional help.