FreshMvvm icon indicating copy to clipboard operation
FreshMvvm copied to clipboard

Write Unit Test with App using FreshMvvm?

Open TohWei opened this issue 7 years ago • 2 comments

Hi, I am interested on how to write Unit Test with Application that built using FresshMvvm. Would be usefuly if you can provide a full sample of a Test Project on how to test methods, properties in PageModel. Particularly on how to test the injection via contructor, etc.

Thanks.

TohWei avatar Aug 24 '17 09:08 TohWei

@TohWei (cc: @rid00z ) - Did you find any example(s)? I'm also curious on the topic, thanks in advance!

azucchitmg avatar Oct 10 '18 22:10 azucchitmg

Creating unit tests is pretty simple, in your view model tests you just have to mock theIPageCoreMethods then use your mock: Example below using moq:

mockCoreMethods = new Mock<IPageModelCoreMethods>();
ViewModel.CoreMethods = mockCoreMethods.Object;

then just set up your expectations:

mockCoreMethods.Setup(x => x.PushPageModel<NewPageModel>();

Hope that helps.

killer-frog avatar Jan 08 '19 14:01 killer-frog