8

I'm creating a library for Universal Windows Platform apps ("Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" under dependencies and "uap10.0": {} under frameworks in project.json). I just started writing tests, but I can't seem to find any mocking library which would support the Universal Windows Platform apps. The only one is MoqaLate, but it's very new and severely limited.

I can't see myself testing without mocks, but I'm also new to UWP development. Am I missing something, or it really is impossible to use mocks in my tests? If so, what are alternatives?

Edit: One alternative I see is to develop Windows Class Library (Portable) which would target only Windows Universal 10.0. Is there any gotcha with this approach I should be careful about? My goal is to have a library that can be used in Windows 10 apps (on mobile, desktop and xbox).

wasyl
  • 3,421
  • 3
  • 27
  • 36

1 Answers1

0

Windows 10 uses .NET native to compile release builds down to machine code, so you are no longer working with MSIL and therefore the techniques used by mocking frameworks (IL weaving etc) cannot be used. However, in debug mode your Windows 10 app runs standard .NET IL (for faster build / debugging cycles) so any mocking framework should work in debug mode as long as you only use it in a PCL project.

Dean Chalk
  • 20,076
  • 6
  • 59
  • 90
  • Can I somehow use Windows 10 library in PCL project? I think I tried it and it didn't work, did I miss something? I understand your answer as in I could still deveop UWP library, but test using PCL project in debug mode – wasyl Sep 23 '15 at 15:58
  • why would you use a platform library. Are you intending to try and mock UI components ? – Dean Chalk Sep 23 '15 at 16:02
  • 3
    No, I'm tasked to create Windows 10 UWP library. But I can't add any testing framework, nuget says it's incompatible with UWP. All I want are regular unit tests with mocks for my UWP library – wasyl Sep 23 '15 at 16:03