本文整理汇总了C#中Basket.AddItemsToTheBasket方法的典型用法代码示例。如果您正苦于以下问题:C# Basket.AddItemsToTheBasket方法的具体用法?C# Basket.AddItemsToTheBasket怎么用?C# Basket.AddItemsToTheBasket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Basket
的用法示例。
在下文中一共展示了Basket.AddItemsToTheBasket方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCheckOutTheSelectedItemsFromTheBasket
public void ShouldCheckOutTheSelectedItemsFromTheBasket()
{
var item1 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var item2 = new Item { ProductName = "Milk", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
IBasket basket = new Basket();
basket.AddItemsToTheBasket(item1);
basket.AddItemsToTheBasket(item2);
var checkout = new Checkout(basket);
IList<Item> itemsForCheckout = checkout.ItemsSelectedForCheckOut().ToList();
Assert.That(itemsForCheckout.Count, Is.EqualTo(2));
}
示例2: ShouldCalculateThePriceForTheChekedOutItems
public void ShouldCalculateThePriceForTheChekedOutItems()
{
var item1 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var item2 = new Item { ProductName = "Milk", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
int totalPrice = 5;
IBasket basket = new Basket();
basket.AddItemsToTheBasket(item1);
basket.AddItemsToTheBasket(item2);
var checkout = new Checkout(basket);
var actual = checkout.CalculatePriceForcheckOut();
Assert.That(actual,Is.EqualTo(totalPrice));
}
示例3: ShouldAddSalePriceToTheItem
public void ShouldAddSalePriceToTheItem()
{
var item1 = new Item { ProductName = "Butter", PriceOfProduct = "10", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013,11,12) };
var item2 = new Item { ProductName = "Milk", PriceOfProduct = "20", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013,11,12) };
var basket = new Basket();
basket.AddItemsToTheBasket(item1);
basket.AddItemsToTheBasket(item2);
Assert.That(item1.SalePrice,Is.EqualTo(5));
Assert.That(item2.SalePrice,Is.EqualTo(10));
var checkout = new Checkout(basket);
var calculatePriceForcheckOut = checkout.CalculatePriceForcheckOut();
Assert.That(calculatePriceForcheckOut,Is.EqualTo(15));
}
示例4: ShouldAddItemsToTheBasket
public void ShouldAddItemsToTheBasket()
{
var basket = new Basket();
var item2 = new Item { NoOfProducts = 2, PriceOfProduct = "3", ProductName = "Milk", ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
int count = basket.AddItemsToTheBasket(item2).Count;
Assert.That(count, Is.EqualTo(1));
}
示例5: ShouldDeleteItemFormTheBasket
public void ShouldDeleteItemFormTheBasket()
{
var item2 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var item3 = new Item { ProductName = "Butter", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var basket = new Basket();
basket.AddItemsToTheBasket(item3);
basket.AddItemsToTheBasket(item2);
basket.DeleteItemFromTheBasket(item2);
Assert.That(basket.list.Count,Is.EqualTo(1));
}
示例6: ShouldRemoveItemsFromTheBasket
public void ShouldRemoveItemsFromTheBasket()
{
//use mock
var item1 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var item2 = new Item { ProductName = "Milk", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var basket = new Basket();
basket.AddItemsToTheBasket(item1);
basket.AddItemsToTheBasket(item2);
IList<Item> itemsFormTheBasket = basket.RemoveItemsFormTheBasket(item1);
Assert.That(itemsFormTheBasket.Count, Is.EqualTo(1));
}
示例7: ShouldIncrementTheCountOfNoOfProductsWhenSameItemAdded
public void ShouldIncrementTheCountOfNoOfProductsWhenSameItemAdded()
{
var item2 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var item3 = new Item { ProductName = "Butter", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
var basket = new Basket();
IList<Item> listOfItems = basket.AddItemsToTheBasket(item3);
Assert.That(listOfItems.Count, Is.EqualTo(1));
listOfItems = basket.AddItemsToTheBasket(item2);
Item listItem = listOfItems.FirstOrDefault(l => l.ProductName == item2.ProductName);
if (listItem != null)
Assert.That(listItem.NoOfProducts, Is.EqualTo(item3.NoOfProducts));
Assert.That(listOfItems.Count, Is.EqualTo(1));
}