Im trying to find a good mocking framework to Unittest my UWP App, bt it seems that all good Mocking infrastructures (MOQ, RhinoMocks etc) understandably rely on Dynamic Proxies which is not supported in UWP.
It looks like MOQ knows of this limitation:
https://github.com/Moq/moq4/issues/195
And Microsoft is less than helpful in this situation:
https://social.msdn.microsoft.com/Forums/en-US/652b9d16-c4ab-401c-9239-0af01108e460/uwp-is-there-any-indication-that-windows-10-uwp-universal-applications-will-support-code-emitting?forum=wpdevelop
Is there any Mocking infrastructure for unittesting UWP apps? Or any ideas if Dynamic Proxy support is coming anytime in the near future for UWP?
Thanks!
We (Microsoft BigPark Studio) have just released a mocking framework that is compatible with UWP, .NetCore and .Net Framework (Nuget Etg.SimpleStubs
). The framework uses Roslyn to generate stubs.
To get around the Reflection.Emit
restriction in UWP, the framework generates the stubs at compile time. The stubs are generated and compiled in one step (during the build). If you've ever used VS Fakes, the experience is very similar.
SimpleStubs is opensource and available as a NuGet:
Docs: https://github.com/Microsoft/SimpleStubs
NuGet: https://www.nuget.org/packages/Etg.SimpleStubs/
There is now a framework called HyperMock which performs mocking in a similar way to other frameworks on the .NET platform.
Visit HyperMock
As this is available via Nuget, you can find it via the package manager with HyperMock.Universal or install it via the package console
Install-Package HyperMock.Universal
Use the Universal version for the UWP projects.