本文整理汇总了C#中FakeRepository.GetProducts方法的典型用法代码示例。如果您正苦于以下问题:C# FakeRepository.GetProducts方法的具体用法?C# FakeRepository.GetProducts怎么用?C# FakeRepository.GetProducts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FakeRepository
的用法示例。
在下文中一共展示了FakeRepository.GetProducts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: No_Price_Less_Than_One_Dollar
public void No_Price_Less_Than_One_Dollar()
{
// Arrange
FakeRepository repo = new FakeRepository();
decimal reductionAmount = decimal.MaxValue;
MyPriceReducer target = new MyPriceReducer(repo);
// Act
target.ReducePrices(reductionAmount);
// Assert
foreach (Product prod in repo.GetProducts()) {
Assert.IsTrue(prod.Price >= 1);
}
}
示例2: Correct_Total_Reduction_Amount
public void Correct_Total_Reduction_Amount()
{
// Arrange
FakeRepository repo = new FakeRepository();
decimal reductionAmount = 10;
decimal initialTotal = repo.GetTotalValue();
MyPriceReducer target = new MyPriceReducer(repo);
// Act
target.ReducePrices(reductionAmount);
// Assert
Assert.AreEqual(repo.GetTotalValue(),
(initialTotal - (repo.GetProducts().Count() * reductionAmount)));
}
示例3: All_Prices_Are_Changed
public void All_Prices_Are_Changed()
{
// Arrange
FakeRepository repo = new FakeRepository();
decimal reductionAmount = 10;
IEnumerable<decimal> prices = repo.GetProducts().Select(e => e.Price);
decimal[] initialPrices = prices.ToArray();
MyPriceReducer target = new MyPriceReducer(repo);
// Act
target.ReducePrices(reductionAmount);
// Assert
prices.Zip(initialPrices, (p1, p2) => {
if (p1 == p2) {
Assert.Fail();
}
return p1;
});
}