locked
Unit testing FFImageLoading and calling CachedImageRenderer.Init? RRS feed

  • Question

  • User372105 posted

    I am trying to create unit test that calls methods that are dependent of FFImageLoading.Forms.CachedImage . I get this exception: System.Exception: Please call CachedImageRenderer.Init method in a platform specific project to use FFImageLoading! How can I call this method from a test project? Will I have to create platform specific code snippet that calls init? Or is there any other way around it?

    Friday, January 4, 2019 1:13 PM

All replies

  • User345835 posted

    Add CachedImageRenderer.Init(); in "OnCreate" function in MainActivity.cs class of your android project and in FinishedLaunching function in AppDelegate class of your iOS project

    Tuesday, January 8, 2019 2:05 PM
  • User372105 posted

    @Elandaloussiishrak said: Add CachedImageRenderer.Init(); in "OnCreate" function in MainActivity.cs class of your android project and in FinishedLaunching function in AppDelegate class of your iOS project

    I have already done that. But I wonder how to call methods depending on CacheImage from MsTest or xUnit test project?

    Wednesday, January 9, 2019 11:13 AM
  • User391003 posted

    @Lelo I had the same issue and after searching through lots of code in their official github page i found something that helped.

    Add this to your unit test "Setup"; FFImageLoading.ImageService.EnableMockImageService = true;

    Example; [BeforeScenario()] public void BeforeScenarioSetup() { base.Setup(); MockForms.Init("Android"); * FFImageLoading.ImageService.EnableMockImageService = true; * }

    Hope this helps

    Tuesday, December 10, 2019 6:58 PM