Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Unit Test Project Does Not Detect Dependency Service

$
0
0

Hello,

I have built a Xamarin.Forms application and used the dependency service mechanism to access platform specific (iOS and Android) features.
At runtime, DependencyService.Get<>() returns the expected object and the app runs fine on both iOS and Android.

However, when trying to unit test (i.e. using the NUnit project for Android), the same DependencyService.Get<>() does not return the expected object anymore. The obvious thing to do was to reference both the .Droid application and the portable library. Also, tried to add the definitions for the dependency services to the unit test project as well. Same result.

Any insight on how to build unit tests for classes that use dependency services?

Thanks!


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>