Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the mocking framework of choice in Unit Test Library for Windows Store Applications? [closed]

When I write unit tests I like to use Rhino Mocks.

So when I started my first Windows Store application I naturally started with my unit tests first. When I tried to add RhinoMocks via NuGet I recieved the following error

Could not install package 'RhinoMocks 3.6.1'. You are trying to install this package into a project that targets '.NETCore,Version=v4.5', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.

I had the same issue with Moq.

Is there a mocking framework for .NETCor,Version=v4.5?

like image 897
David Basarab Avatar asked Aug 23 '12 01:08

David Basarab


People also ask

What should be mocked in unit tests?

Mocking is a process used in unit testing when the unit being tested has external dependencies. The purpose of mocking is to isolate and focus on the code being tested and not on the behavior or state of external dependencies.

What does mocking mean in unit testing?

Mocking means creating a fake version of an external or internal service that can stand in for the real one, helping your tests run more quickly and more reliably. When your implementation interacts with an object's properties, rather than its function or behavior, a mock can be used.

What are mocking frameworks?

When unit testing, you are often interested in testing a portion of a complete system isolated from dependencies. To test a portion of the system, we can use mock objects to replace the dependencies.

Which of the following are the mocking framework?

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.


2 Answers

Most mocking frameworks are based on Reflection.Emit. Unfortunately Reflection.Emit isn't in WinRT. This means you can't do dynamic proxies. (I.e. Run-time mocking). This leaves pre-generation of mocks that get referenced at compile-time. The only framework I know of is an experimental branch of Moq: https://github.com/mbrit/moqrt

like image 174
Peter Ritchie Avatar answered Sep 21 '22 00:09

Peter Ritchie


I made this for use with Windows Phone 7, should work with Win 8 as it's just a post build step:

http://dontcodetired.com/blog/post/Introducing-%28probably%29-The-Worlds-Only-Mocking-Framework-for-Windows-Phone-7-%28WP7%29.aspx

like image 35
Jason Roberts Avatar answered Sep 21 '22 00:09

Jason Roberts