I use Moq. But I can not use with Nemerle.
public interface IBudgetRepo
{
List(): IEnumerable[string];
}
[Test]
public Tes1(): void
{
def repo = Mock.[IBudgetRepo]();
repo.Setup(r=>r.List()).Return(null);
}
Compiler error
Error each overload has an error during call: Overload #1, method
Moq.Mock.Setup(expression :
System.Linq.Expressions.Expression[System.Func[T, TResult]]) :
Moq.Language.Flow.ISetup[T, TResult]. In argument #1 (expression) of
repo.Setup.[?], needed a
System.Linq.Expressions.Expression[System.Func[Money.Model.IBudgetRepo, ?]],
got ? -> ?: Money.Model.IBudgetRepo -> ? is not a subtype of
System.Linq.Expressions.Expression[System.Func[Money.Model.IBudgetRepo, ?]]
[simple require]. Overload #2, method Moq.Mock.Setup(expression :
System.Linq.Expressions.Expression[System.Action[T]]) :
Moq.Language.Flow.ISetup[T]. In argument #1 (expression) of
repo.Setup, needed a
System.Linq.Expressions.Expression[System.Action[Money.Model.IBudgetRepo]],
got ? -> ?: Money.Model.IBudgetRepo -> void is not a subtype of
System.Linq.Expressions.Expression[System.Action[Money.Model.IBudgetRepo]]
[simple require]
How can I use Moq?
Though there is a way to convert lambdas to expressions with Vlad's
linq macro which includes ToExpression macro that you use it as
ToExpression( x=>y)
Here's the test code for it :
http://code.google.com/p/nemerle/source/browse/nemerle/trunk/Linq/Testes/Main.n
I hope it helps
using Nemerle.Data.Linq;
...
def mock = Mock.[IMvcCtrl]();
_ = mock.Setup(ToExpression(c=>c.CurrentUser)).Returns(currentUsr);
_ = mock.Setup(ToExpression(c=>c.TimeZoneOffset)).Returns(0);
MvcCtrlWrap(mock.Object);