smstuebe / xamarin-fingerprint

Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor
Microsoft Public License
490 stars 115 forks source link

Possiblity to mock CrossFingerprint has been added #61

Closed ArtjomP closed 6 years ago

smstuebe commented 7 years ago

Thanks for the PR.

Why do we need this? Usually, the IFingerprint implementation / mock should get injected via constructor or a auto wiring mechanism. This means, the dependency is passed from outside. Using static dependencies, is not so nice. Should I really support it or force the user of this plugin to design his code a bit better? :P

ArtjomP commented 7 years ago

This is a good question which way is the best one. I don't know. Setting .Current is a second approach to use a mock implementation. And this approach was described here: http://motzcod.es/post/159267241302/unit-testing-plugins-for-xamarin . May be some dependency service requires only constructor for interface specialization. Or just a developer doesn't know how to do it (Actually I'm looking now how to do it with Prism). I, personally, like this approach. It makes my ViewModel constructors a little bit shorter :) You bet.