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

Can't mock extension method in Paid Version

2 Answers 56 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 12 Oct 2012, 07:34 PM
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 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 12 Oct 2012, 07:41 PM
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

0
Ricky
Telerik team
answered on 15 Oct 2012, 08:21 AM
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.

Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Ricky
Telerik team
Share this question
or