chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
On the TypeB_CallEvents.cs I tried to create a new mocked object the MockMethodCalledEventHandler like this:

private void productMock_MockMethodCalled(object sender,MockMethodCallEventArgs e)
{

countCalls++;

IProduct product = ProductFactory.GetProduct("name2");

Assert.AreEqual(false,e.WillThrowException);

}

I noticed that the product object created by the GetProduct method is not a mocked object - if it's a mocked object, the Price property should be 11F.

Could you tell me why it happened that way? and Is it possible to create a new mocked object inside the event handler? Basically, I'd like to pass it to another method or MockedEvent as an event argument.

Thanks in advance.
asked by Siriwat (640 points)

2 Answers

0 votes
Hi
You can not create a mock object inside the event handler for MockMethodCalled event.
However if you have the enterprise licence you can use Dynamic Return Values to do this.
Hope it helps.
answered by ohad (35.4k points)
0 votes
Cool! thanks for your prompt reply. I'll try again.
answered by Siriwat (640 points)
...