我对此很陌生,所以毫无疑问我在做一些愚蠢的事情。
我正在尝试创建一个模拟对象:
mockCurrencyConversion = mocks.NewMock<ICurrencyConversion>();
并收到此错误:
非泛型方法“NMock2.Mockery.NewMock(System.Type)”不能与类型参数一起使用
ICurrency 转换:
public interface ICurrencyConversion
{
decimal convertCurrency(string fromCurrency, string toCurrency, decimal amount);
int addNumbers(int i, int j);
decimal getRate(CurrencyRateResponse rates, string fromCurrency);
CurrencyRateResponse getCurrencyRates();
HttpWebRequest GetWebRequest(string formattedUri);
}
我的测试代码:
[TestFixture]
public class WhygoTest
{
private Mockery mocks;
private ICurrencyConversion mockCurrencyConversion;
[SetUp]
public void SetUp()
{
mocks = new Mockery();
mockCurrencyConversion = mocks.NewMock<ICurrencyConversion>();
}
[Test]
public void MyAddTest()
{
var cc = new CurrencyConversion();
Assert.AreEqual(cc.addNumbers(1, 2), 3);
}
}