[英]Does Moq mocking library for .NET 3.5 work with mono?
I'm trying to use Moq on a Mono / .NET 3.5 Project using MonoDevelop for MacOS X我正在尝试在使用 MonoDevelop for MacOS X 的 Mono / .NET 3.5 项目上使用 Moq
I've tried the sample C# code:我已经尝试过示例 C# 代码:
var mock = new Mock<IFoo>();
mock.Setup((foo => foo.DoSomething("ping"))).Returns(true);
With IFoo beeing:使用 IFoo 蜜蜂:
public interface IFoo
{
bool DoSomething(string a);
}
But I keep getting the following compiler errors on the mock.Setup line:但是我在 mock.Setup 行上不断收到以下编译器错误:
Error CS1660: Cannot convert `lambda expression' to non-delegate type `System.Linq.Expressions.Expression<System.Action<Test.IFoo>>' (CS1660) (Test)
Error CS1502: The best overloaded method match for `Moq.Mock<Test.IFoo>.Setup(System.Linq.Expressions.Expression<System.Action<Test.IFoo>>)' has some invalid arguments (CS1502) (Test)
Error CS1503: Argument `#1' cannot convert `anonymous method' expression to type `System.Linq.Expressions.Expression<System.Action<Test.IFoo>>' (CS1503) (Test)
Am I doing something wrong or it´s just that Mono is not yet ready for Moq?我做错了什么还是只是 Mono 还没有准备好起订量?
Like said in Preet Sangha 's comment:就像Preet Sangha的评论中所说:
Add a reference to System.Core
添加对
System.Core
的引用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.