Mock component method #600
Unanswered
harshvirani911
asked this question in
Q&A
Replies: 1 comment 8 replies
-
@harshvirani911, to mock a method in any a component (and for that matter in any class), you need to mock the component/class itself. Here is the general approach:
Step 1 and 2 depends on the mocking framework you use. For that, I refer you to the frameworks documentation. For step 3, see this bUnit doc page: https://bunit.dev/docs/providing-input/substituting-components.html#creating-a-mock-component-with-mocking-libraries |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @egil ,How to mock component method?
Component:
public partial class DemoTemplate{
public async Task ValidateDemoAsync(string DemoKey){
if(DemoKey == "1"){return true;}
else{
return false;
}
}
}
For above i need to mock ValidateDemoAsync, how can we do?
Beta Was this translation helpful? Give feedback.
All reactions