本文整理汇总了C#中Order.AddItems方法的典型用法代码示例。如果您正苦于以下问题:C# Order.AddItems方法的具体用法?C# Order.AddItems怎么用?C# Order.AddItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.AddItems方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAffiliateDiscount
public void TestAffiliateDiscount()
{
var orderMgm = new OrderManagement(_repository);
Order order = new Order();
order.UserId = 2;//Affiliate
order.Id = OrderManagement.CreateOrderId();
//Add Items
order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 20 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 40 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 10 });
orderMgm.ProcessOrder(order);
//Expectation
//GrossAmount=70
//Discount=10% of non grocery items discount = 10% of 20=2
//Net Amount= 70-2=68
Assert.AreEqual(70, order.GrossAmount);
Assert.AreEqual(68, order.NetPayableAmount);
Assert.AreEqual(2, order.TotalDiscount);
}
示例2: TestPercentageDiscountAppliedOnGrocery
public void TestPercentageDiscountAppliedOnGrocery()
{
var orderMgm = new OrderManagement(_repository);
Order order = new Order();
order.UserId = 1;//employee
order.Id = OrderManagement.CreateOrderId();
//Add Items
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 1, Price = 200 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 250 });
orderMgm.ProcessOrder(order);
//All items are grocery
//Only this will be applicable: "For every $100 on the bill, there would be a $ 5 discount"
Assert.AreEqual(850, order.GrossAmount);
Assert.AreEqual(810, order.NetPayableAmount);
Assert.AreEqual(40, order.TotalDiscount);
}
示例3: TestNormalCustomerDiscount
public void TestNormalCustomerDiscount()
{
var orderMgm = new OrderManagement(_repository);
Order order = new Order();
order.UserId = 4;//Normal Customer
order.Id = OrderManagement.CreateOrderId();
//Add Items
order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 200 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 150 });
orderMgm.ProcessOrder(order);
//Expectation
Assert.AreEqual(750, order.GrossAmount);
Assert.AreEqual(715, order.NetPayableAmount);
Assert.AreEqual(35, order.TotalDiscount);
}
示例4: TestOldCustomerDiscount
public void TestOldCustomerDiscount()
{
var orderMgm = new OrderManagement(_repository);
Order order = new Order();
order.UserId = 3;//Old Customer
order.Id = OrderManagement.CreateOrderId();
//Add Items
order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 200 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 150 });
orderMgm.ProcessOrder(order);
//Expectation
//discount on apparel 10% = 20
//discount amount 7*5=35
//totaldiscount=45
Assert.AreEqual(750, order.GrossAmount);
Assert.AreEqual(695, order.NetPayableAmount);
Assert.AreEqual(55, order.TotalDiscount);
}
示例5: TestIfUserIsAssociatedWithOrder
public void TestIfUserIsAssociatedWithOrder()
{
var orderMgm = new OrderManagement(_repository);
Order order = new Order();
order.Id = OrderManagement.CreateOrderId();
//Add Items
order.AddItems(new Item() { Category = ItemCategory.Apparel, Id = 1, Price = 200 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 2, Price = 400 });
//Add grocery Item
order.AddItems(new Item() { Category = ItemCategory.Grocery, Id = 3, Price = 150 });
orderMgm.ProcessOrder(order);
}