No matter how I try, I cannot mimic the clean syntax of Rhino Mocks, without declaring a delegate.
Example:
Expect.Call(service.HelloWorld("Thanks"))
Do you have any idea on how to do this?
Thanks.
No matter how I try, I cannot mimic the clean syntax of Rhino Mocks, without declaring a delegate.
Example:
Expect.Call(service.HelloWorld("Thanks"))
Do you have any idea on how to do this?
Thanks.
Using Lambda syntax in 3.5 you can get a similar syntax.
public void Call(Action action)
{
action();
}
Expect.Call(() => service.HelloWorld("Thanks"));
Moq is a mocking framework that uses Lambda syntax for it's mocking.
var mock = new Mock<IService>();
mock.Setup(service => service.HelloWorld("Thanks")).Returns(42);
You could use the Action delegate provided in newer versions of .NET
void Execute(Action action) {
action();
}
void Test() {
Execute(() => Console.WriteLine("Hello World!"));
}