本文整理汇总了C#中Solution.OrderMultiple方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.OrderMultiple方法的具体用法?C# Solution.OrderMultiple怎么用?C# Solution.OrderMultiple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solution
的用法示例。
在下文中一共展示了Solution.OrderMultiple方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_order_with_too_big_package
public void Test_order_with_too_big_package()
{
var sut = new Solution();
var products = new Products {{"A", 1}};
var price = 0;
sut.Setup(products, new ProductPackages {new ProductPackage {Price = 6, Products = Enumerable.Repeat("A", 8).ToList()}});
sut.SendPrice += p => price = p;
sut.OrderMultiple(7, "A");
price.Should().Be(7, "6 would be to many As");
}
示例2: Test_performance
public void Test_performance()
{
var sut = new Solution();
var products = new Products {{"A", 10}, {"B", 20}, {"C", 30}};
var productPackages = new ProductPackages
{
new ProductPackage {Price = 29, Products = new List<string> {"A", "B"}},
new ProductPackage {Price = 30, Products = new List<string> {"A", "A", "A", "A"}},
new ProductPackage {Price = 48, Products = new List<string> {"B", "C"}},
new ProductPackage {Price = 57, Products = new List<string> {"A", "B", "C"}}
};
sut.Setup(products, productPackages);
sut.SendPrice += price => Console.WriteLine("{0,3}. Order, Price: {1,5}", count++, price);
//sut.OrderMultiple(50, "A");
//sut.OrderMultiple(5, "B");
//sut.OrderMultiple(3, "C");
sut.OrderMultiple(40, "A");
sut.OrderMultiple(40, "B");
sut.OrderMultiple(40, "C");
}
示例3: Test_order_where_it_is_not_better_to_take_highest_discount
public void Test_order_where_it_is_not_better_to_take_highest_discount()
{
var sut = new Solution();
var products = new Products { { "A", 10 } };
var productPackages = new ProductPackages
{
new ProductPackage {Price = 47, Products = new List<string> {"A", "A", "A", "A", "A"}}, // discount 3/5 pp
new ProductPackage {Price = 38, Products = new List<string> {"A", "A", "A", "A"}} // discount 1/2 pp
};
var price = 0;
sut.Setup(products, productPackages);
sut.SendPrice += p => price = p;
sut.OrderMultiple(8, "A");
price.Should().Be(2 * 38);
}