-
Notifications
You must be signed in to change notification settings - Fork 1
Description and Quickstart
ciscoheat edited this page Oct 12, 2010
·
9 revisions
umock is a library for creating mock objects of Interfaces and (when possible) Classes.
Consider this little interface:
interface IPoint {
var x : Int;
var y : Int;
function length() : Int;
}
With umock, we can mock this interface like this:
import umock.Mock;
...
var mock = new Mock<IPoint>(IPoint);
mock.setupField("x").returns(10);
mock.setupField("y").throws("One dimension only, thank you.");
mock.setupMethod("length").returns(1000);
Setting parameter constraints is also possible:
mock.setupMethod("someMethod").withParams(It.IsAny(Int), "123").returns(1000);
So are callbacks and lazy return evaluation:
mock.setupMethod("someMethod").returns(1000).callBack(function() { i++; });
mock.setupMethod("someMethod").returnsLazy(function() { return 100+i; });
And finally, verifying the results:
mock.verify("length", Times.atLeastOnce());
Right now the following platforms are supported:
- Neko
- Php
- Javascript
This library is heavily influenced by the great Moq library for .NET.