FreshMvvm
FreshMvvm copied to clipboard
Write Unit Test with App using FreshMvvm?
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 (cc: @rid00z ) - Did you find any example(s)? I'm also curious on the topic, thanks in advance!
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.