Although there are many syntax mistakes in your code (which is a sign that this might not be the real code problem). When I fix them I get the correct result:
TestCase 'TestUsingTypeMock.Test35.Topic260'
failed: TypeMock.VerifyException :
TypeMock Verification: Call to TestUsingTypeMock.class2.start() Parameter: 1
passed object [TestUsingTypeMock.class2+StartEventHandler] is not controlled by expected mock.
Suppose that you want to check that the correct event has been passed. You can do that as follows, using a Custom Checker
[Test]
public void Topic260()
{
MockManager.Init();
Mock mockClass2 = MockManager.MockAll(typeof(class2));
class1 c1 = new class1();
mockClass2.ExpectCall("start").Args(Check.CustomChecker(CheckEventHandlerPassed,c1));
c1.doSomething();
MockManager.Verify();
}
// Here we will check that the correct method is send
private bool CheckEventHandlerPassed(ParameterCheckerEventArgs e)
{
Delegate d = (Delegate) e.ArgumentValue ;
class1 c1 = (class1)e.ExpectedValue;
if (object.ReferenceEquals(c1, d.Target) &&
d.Method.Name == "startDoSomething")
{
return true;
};
return false;
}
Of course, perhaps a better way is to check that our event handler is called (I don't know the code so Im guessing)
[Test]
public void Topic260()
{
MockManager.Init();
Mock mockClass1 = MockManager.Mock(typeof(class1));
mockClass1.ExpectCall("startDoSomething");
class1 c1 = new class1();
c1.doSomething();
c1.MakeClass2ToFireEvent();
// make sure out event was called once.
MockManager.Verify();
}