This is a migrated thread and some comments may be shown as answers.

Mock non virtual methods?

4 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Florian
Top achievements
Rank 1
Florian asked on 05 Oct 2015, 06:58 PM
Is there a way to mock non virtual public/protected methods? I see it's possible for private but not for protected and public.

4 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Oct 2015, 08:26 AM
Hello Florian,

JustMock supports mocking of non-virtual methods, but only when the profiler is enabled. Non-virtual method mocking is not available in JustMock Lite.

Public methods are mocked using the Mock.Arrange(() => ...) syntax. Both private and protected methods are mocked using Mock.NonPublic.Arrange(...). I don't understand how you came to the conclusion that only private methods are supported. Maybe you can share a snippet showing what you're trying to accomplish?

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Florian
Top achievements
Rank 1
answered on 06 Oct 2015, 03:54 PM

Hi,

Thanks for your answer. I didn't notice this capability before and I thought that shd work the same as for mocking private methods (i.e. using the method name). It's OK now

0
Boris
Top achievements
Rank 1
answered on 13 Nov 2020, 08:19 AM
what profiler should be enabled? what am I to do to enable it?
0
Ivo
Telerik team
answered on 16 Nov 2020, 11:48 AM

Hello Boris,

You have to use the full version of the product, for more information about the supported features, please refer to the feature comparison matrix. On this page, you can also find a link for downloading a free trial.

Regards,
Ivo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Florian
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Florian
Top achievements
Rank 1
Boris
Top achievements
Rank 1
Ivo
Telerik team
Share this question
or