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?
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.
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With