在学习MVC3的单元测试的时候碰到一个奇怪的事情:

 

[TestClass]
public class MyPriceReducerTest
{
[TestMethod]
public void All_Prices_Are_Changed()
{
FakeResponsitory repo = new FakeResponsitory();
decimal reductionAmount = 10;

IEnumerable<decimal> prices = repo.GetProducts().Select(e => e.Price);
decimal[] intialPrices = prices.ToArray();
}
}

 

其中repo.GetProducts().Select(e=>e.Price) 报错,说是没有该方法

百思不得其解 ,后来对比单元测试项目的引用和项目的引用才发现,少了引用System.Linq

 

VS2010一般新建项目都会自动引用该引用,不知道为什么单元测试ide项目没有引用,哎,花了好长时间才找到这个错误,

看来还是基础不牢啊!

相关文章:

  • 2021-07-20
  • 2021-07-28
  • 2021-12-18
  • 2021-11-05
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2022-01-24
  • 2022-02-26
  • 2021-08-03
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案