Mock non virtual methods?

3 posts, 0 answers
  1. Florian
    Florian avatar
    9 posts
    Member since:
    Jul 2015

    Posted 05 Oct 2015 Link to this post

    Is there a way to mock non virtual public/protected methods? I see it's possible for private but not for protected and public.
  2. Stefan
    Stefan avatar
    198 posts

    Posted 06 Oct 2015 Link to this post

    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?

    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
  3. Florian
    Florian avatar
    9 posts
    Member since:
    Jul 2015

    Posted 06 Oct 2015 in reply to Stefan Link to this post


    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

Back to Top