c# - How to mock viewmodel which is not a parameter of the action? -


Below is the code snippet of my work: -

  Editing Public Function (Int ID ) {ProductViewModel viewmodel = GetProduct (ID); If (View model! = Null) {....................}}   

if the code above is based on condition View MODEL. Which is returning to the GetProduct () method. Where GetProduct () method is the private method of the controller.

And I want to duplicate ProductViewModel in my unit. Exam method with MOQ Can someone suggest me what is the best way to do this?

Ideally your view model is only the public properties for which your ideas will be bound, so no such scenario Must be where you should be duplicate the View Model class. If this is possible, then duplicate the GetProduct method to return an incident to the productive visual model where the public property has already been set. In this way, your visual model will return your values, which you would like you to return it to your test case.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -