This is exactly TypeMock's value, you can mock *future* instances .
So if you have this code in class TestedClass
class TestedClass
{
int something;
public void PublicMethod()
{
PrivateMethod();
}
private void PrivateMethod()
{
YourClass c1 = new YourClass();
YourClass c2 = new YourClass();
YourClass c3 = new YourClass();
something = c3.DoSomething();
}
And you want to mock the 3rd instance (c3) that DoSomething should return 5 for example, you can do it like this
// No expectations: will run all normal -for first 2 instances
MockManager.Mock(typeof(YourClass));
MockManager.Mock(typeof(YourClass));
// Mock and add expectations for 3rd instance
Mock mock MockManager.Mock(typeof(YourClass));
mock.ExpectAndReturn("DoSomething",5);
TestedClass t = new TestedClass();
t.PublicMethod();
Now the TestedClass.something will equal 3.