Can't mock extension method in Paid Version

3 posts, 0 answers
  1. Daniel
    Daniel avatar
    2 posts
    Member since:
    Oct 2012

    Posted 12 Oct 2012 Link to this post

    I'm using the Paid version but can't seem to mock an extension method -- I've tried the following
    Mock.Arrange(() => target.SomeExtensionMethod(1)).DoNothing();

    where target is a concrete (non-mocked) object as well as just

    Mock.Arrange(() => StaticClass.AddLinkableObject(1)).DoNothing();

    Where StaticClass is the class where the extension method is defined.

    As soon as my code hits the Arrange line I get the following exception-

    Profiler must be enabled to mock/assert target blah, blah method.

    Thanks
  2. Daniel
    Daniel avatar
    2 posts
    Member since:
    Oct 2012

    Posted 12 Oct 2012 Link to this post

    Sorry for replying to myself but I seem to have gotten past the exception being thrown on the Arrange -- somehow JustMock was
    disabled and enabling it made the aforementioned exception go away. However the Extension Method is still being called even though I've arranged JustMock to do nothing thusly

    Mock.Arrange(() => SomeObject.MyExtensionMethod(1)).DoNothing();

    and yes, it is being called with the argument indicated.

    Thanks

  3. DevCraft R3 2016 release webinar banner
  4. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 15 Oct 2012 Link to this post

    Hi Daniel,

    Thanks again for contacting us. 

    However, I would request you to send me a sample project which I can use to investigate the issue further. Since, it is not reproducible at my end. 

    Kind Regards
    Ricky
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top