npm install moqjs --save-dev
Using the Code
The framework does not work exactly as Moq used to because of the lack of interfaces in run time.
So, the next best thing is to change the behaviour of existing objects.
This is why I decided the term mock is not appropriate and switched to the term mole which is more suitable here.
Some basic examples are given below:
var dog = new Dog();
var mole = new Mole(dog);
mole.setup(_dog => _dog.eat('meat')).returns('Yum yum yum');
var result = dog.eat('meat');
var isVerified = mole.verify(_dog => _dog.eat('meat'), Times.exact(1));
1/4/2016 (version 1.1.0):
- Change the tests to
- Refactor the project to use
- Move the project from VisualStudio to plane folder project
14/4/2016 (version 1.1.1):
- Added public License file
You can find more examples, the build and the code in my git: