Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mocking framework in UWP Apps [closed]

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!

like image 853
Scott Henry Avatar asked Oct 20 '15 16:10

Scott Henry


People also ask

How do I fix UWP app not opening?

Please run Windows Store Apps troubleshooter from Settings app > Update & security > Troubleshoot. See if it helps you. Hope this helps!

What framework does UWP use?

UWP apps use the Windows Runtime, the native API provided by the operating system. This API is implemented in C++ and is supported in C#, Visual Basic, C++, and JavaScript.

What is mocking framework C#?

Mocking Frameworks (Moq, NSubstitute, Rhino Mocks, FakeItEasy, and NMock3) are used to create fake objects. We can stub, i.e., completely replace the body of member and function. It is used to isolate each dependency and help developers in performing unit testing in a concise, quick, and reliable way.


1 Answers

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/SimpleStubs/

like image 131
nbilal Avatar answered Sep 18 '22 21:09

nbilal