7 Answers, 1 is accepted
0
Hello Ignacio,
I am sorry that you have troubles using JustMock.
I know of three different Timers types in BCL: System.Windows.Forms.Timer, System.Timers.Timer and System.Threading.Timer. Which one are you using? I need this information to try and reproduce the behavior on our side.
Regards,
Todor
Telerik
I am sorry that you have troubles using JustMock.
I know of three different Timers types in BCL: System.Windows.Forms.Timer, System.Timers.Timer and System.Threading.Timer. Which one are you using? I need this information to try and reproduce the behavior on our side.
Regards,
Todor
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Nacho
Top achievements
Rank 1
answered on 02 May 2014, 06:56 AM
Hello,
the main issue I'm struggling with is that when you do:
then you cannot put .IgnoreInstance() because the return type of the Raise() method is different from the Arrange() so I cannot use Future Mocking together with Raise().
What I want to do is something like:
That way I will be able to test the eventHandler of the timer inside the TestedClass.
Anyway we are using Timers.Timer just in case it helps.
Regards.
the main issue I'm struggling with is that when you do:
Mock.Raise(xxx,xxx)
then you cannot put .IgnoreInstance() because the return type of the Raise() method is different from the Arrange() so I cannot use Future Mocking together with Raise().
What I want to do is something like:
// Arrange
TestedClass testedClass =
new
TestedClass();
Mock.Arrange(() =>
new
Timer()).DoNothing();
// Act
Mock.Raise(() =>
new
Timer().Elapsed +=
null
,
new
ElapsedEventArgs()).IgnoreInstance();
That way I will be able to test the eventHandler of the timer inside the TestedClass.
Anyway we are using Timers.Timer just in case it helps.
Regards.
0

Nacho
Top achievements
Rank 1
answered on 06 May 2014, 07:53 AM
Hello,
any update on this?
Thanks.
any update on this?
Thanks.
0
Hi Ignacio,
Due to a big holiday in Bulgaria we have reduced support capacity. We will investigate further your issue and will write back to you as soon as possible. I am really sorry for the inconvenience caused!
Regards,
Todor
Telerik
Due to a big holiday in Bulgaria we have reduced support capacity. We will investigate further your issue and will write back to you as soon as possible. I am really sorry for the inconvenience caused!
Todor
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Nacho
Top achievements
Rank 1
answered on 06 May 2014, 03:37 PM
Ok, no worries, at least now I know you didn't forget me :)
0
Hello Ignacio,
I'm sorry for keeping you waiting for so long.
You still need an instance on which to raise the event. Raising the event on all existing timers is likely impractical. I suggest that you use the arrangement on the new expression to get the instance on which to raise the event, like so:
In the above code I get the reference to the created timer using future constructor mocking. Then, I can raise the event on the instance regularly.
I hope this is enough to get your test running.
Cheers!
Stefan
Telerik
I'm sorry for keeping you waiting for so long.
You still need an instance on which to raise the event. Raising the event on all existing timers is likely impractical. I suggest that you use the arrangement on the new expression to get the instance on which to raise the event, like so:
// Arrange
Timer timer =
null
;
Mock.Arrange(() =>
new
Timer()).DoInstead((Timer thisTimer) => timer = thisTimer);
// Act
// first, do the thing that creates the timer
Timer.Do();
// we now have a reference to the timer from the above DoInstead clause
Mock.Raise(() => timer.TheEvent +=
null
);
I hope this is enough to get your test running.
Cheers!
Stefan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Nacho
Top achievements
Rank 1
answered on 07 May 2014, 07:47 AM
Thanks, that solves completely the issue.
Regards.
Regards.